CentOS 7でスクリプトをサービス起動するとプロセスが落ちてしまいます。
ただし、スクリプトを単体で実行するとプロセスは落ちません。
もし原因がおわかりの方がおられましたら、ご教授いただけると幸いです。
何卒、よろしくお願い申し上げます。
###対象ファイル
■スクリプト(/opt/Server.sh)
#!/bin/bash dotnet /opt/Server/Server.Service.dll
■.serviceファイル(/etc/systemd/system/Server.service)
[Unit] Description = Server daemon After = postgresql-9.6.service [Service] ExecStart = /opt/Server.sh Restart = no Type = simple RemainAfterExit = yes [Install] WantedBy = multi-user.target
###実行結果
■スクリプト実行
[root@localhost ~]# /opt/Server.sh [root@localhost ~]# ps aux | grep -e Server -e postgres postgres 970 0.0 1.4 358712 15492 ? Ss 12月21 0:01 /usr/pgsql-9.6/bin/postmaster -D /var/lib/pgsql/9.6/data/ postgres 1073 0.0 0.1 211588 1736 ? Ss 12月21 0:00 postgres: logger process postgres 1075 0.0 0.3 358832 3452 ? Ss 12月21 0:00 postgres: checkpointer process postgres 1076 0.0 0.2 358712 2732 ? Ss 12月21 0:01 postgres: writer process postgres 1077 0.0 0.1 358712 1704 ? Ss 12月21 0:01 postgres: wal writer process postgres 1078 0.0 0.2 359136 2912 ? Ss 12月21 0:01 postgres: autovacuum launcher process postgres 1079 0.0 0.1 213844 1984 ? Ss 12月21 0:02 postgres: stats collector process root 4026 0.0 0.1 113128 1188 pts/2 S+ 10:58 0:00 /bin/bash /opt/Server.sh root 4027 13.4 32.1 3045132 355180 pts/2 SLl+ 10:58 0:50 dotnet /opt/Server/Server.Service.dll postgres 4034 0.0 0.6 360536 7364 ? Ss 10:58 0:00 postgres: db_admin testdb ::1(37332) idle root 4103 0.0 0.0 112676 980 pts/3 R+ 11:04 0:00 grep --color=auto -e Server -e postgres
■サービス起動
[root@localhost ~]# systemctl start Server [root@localhost ~]# systemctl status Server ● Server.service - Server daemon Loaded: loaded (/etc/systemd/system/Server.service; enabled; vendor preset: disabled) Active: active (exited) since 金 2017-12-22 11:11:46 JST; 8s ago Process: 4139 ExecStart=/opt/Server.sh (code=exited, status=0/SUCCESS) Main PID: 4139 (code=exited, status=0/SUCCESS) [root@localhost ~]# ps aux | grep -e Server -e postgres postgres 970 0.0 1.4 358712 15492 ? Ss 12月21 0:01 /usr/pgsql-9.6/bin/postmaster -D /var/lib/pgsql/9.6/data/ postgres 1073 0.0 0.1 211588 1736 ? Ss 12月21 0:00 postgres: logger process postgres 1075 0.0 0.3 358832 3452 ? Ss 12月21 0:00 postgres: checkpointer process postgres 1076 0.0 0.2 358712 2732 ? Ss 12月21 0:01 postgres: writer process postgres 1077 0.0 0.1 358712 1704 ? Ss 12月21 0:01 postgres: wal writer process postgres 1078 0.0 0.2 359136 2912 ? Ss 12月21 0:01 postgres: autovacuum launcher process postgres 1079 0.0 0.1 213844 1984 ? Ss 12月21 0:02 postgres: stats collector process root 4172 0.0 0.0 112676 980 pts/3 R+ 11:19 0:00 grep --color=auto -e Server -e postgres
<追記>
ちなみに、同じようなスクリプトをサービス起動するとプロセスは起動したままになります。
###対象ファイル
■スクリプト(/opt/Send.sh)
#!/bin/bash dotnet /opt/Send/Send.Service.dll
■.serviceファイル(/etc/systemd/system/Send.service)
[Unit] Description = Send daemon After = Server.service [Service] ExecStart = /opt/Send.sh Restart = no Type = simple RemainAfterExit = yes [Install] WantedBy = multi-user.target
###実行結果
■スクリプト実行
[root@localhost ~]# /opt/Send.sh [root@localhost ~]# ps aux | grep -e Send root 4552 0.0 0.1 113128 1188 pts/2 S+ 13:20 0:00 /bin/bash /opt/Send.sh root 4553 0.5 4.6 2653372 51032 pts/2 SLl+ 13:20 0:00 dotnet /opt/Send/Send.Service.dll root 4567 0.0 0.0 112676 980 pts/3 R+ 13:21 0:00 grep --color=auto -e Send
■サービス起動
[root@localhost ~]# systemctl start Send [root@localhost ~]# systemctl status Send ● Send.service - Send daemon Loaded: loaded (/etc/systemd/system/Send.service; enabled; vendor preset: disabled) Active: active (running) since 金 2017-12-22 13:26:01 JST; 2min 20s ago Main PID: 4588 (Send.sh) CGroup: /system.slice/Send.service ├─4588 /bin/bash /opt/Send.sh └─4589 dotnet /opt/Send/Send.Service.dll 12月 22 13:26:01 localhost.localdomain systemd[1]: Started Send daemon. 12月 22 13:26:01 localhost.localdomain systemd[1]: Starting Send daemon... [root@localhost ~]# ps aux | grep -e Send root 4588 0.0 0.1 115252 1448 ? Ss 13:26 0:00 /bin/bash /opt/Send.sh root 4589 0.2 4.5 2653236 50428 ? SLl 13:26 0:00 dotnet /opt/Send/Send.Service.dll root 4612 0.0 0.0 112676 980 pts/3 R+ 13:31 0:00 grep --color=auto -e Send
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/12/22 04:48
2017/12/22 12:54
2017/12/25 02:22