質問編集履歴
1
内容追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -63,4 +63,59 @@
|
|
63
63
|
postgres 1078 0.0 0.2 359136 2912 ? Ss 12月21 0:01 postgres: autovacuum launcher process
|
64
64
|
postgres 1079 0.0 0.1 213844 1984 ? Ss 12月21 0:02 postgres: stats collector process
|
65
65
|
root 4172 0.0 0.0 112676 980 pts/3 R+ 11:19 0:00 grep --color=auto -e Server -e postgres
|
66
|
+
```
|
67
|
+
|
68
|
+
<追記>
|
69
|
+
ちなみに、同じようなスクリプトをサービス起動するとプロセスは起動したままになります。
|
70
|
+
|
71
|
+
###対象ファイル
|
72
|
+
■スクリプト(/opt/Send.sh)
|
73
|
+
```
|
74
|
+
#!/bin/bash
|
75
|
+
dotnet /opt/Send/Send.Service.dll
|
76
|
+
|
77
|
+
```
|
78
|
+
■.serviceファイル(/etc/systemd/system/Send.service)
|
79
|
+
```
|
80
|
+
[Unit]
|
81
|
+
Description = Send daemon
|
82
|
+
After = Server.service
|
83
|
+
|
84
|
+
[Service]
|
85
|
+
ExecStart = /opt/Send.sh
|
86
|
+
Restart = no
|
87
|
+
Type = simple
|
88
|
+
RemainAfterExit = yes
|
89
|
+
|
90
|
+
[Install]
|
91
|
+
WantedBy = multi-user.target
|
92
|
+
```
|
93
|
+
|
94
|
+
###実行結果
|
95
|
+
■スクリプト実行
|
96
|
+
```
|
97
|
+
[root@localhost ~]# /opt/Send.sh
|
98
|
+
[root@localhost ~]# ps aux | grep -e Send
|
99
|
+
root 4552 0.0 0.1 113128 1188 pts/2 S+ 13:20 0:00 /bin/bash /opt/Send.sh
|
100
|
+
root 4553 0.5 4.6 2653372 51032 pts/2 SLl+ 13:20 0:00 dotnet /opt/Send/Send.Service.dll
|
101
|
+
root 4567 0.0 0.0 112676 980 pts/3 R+ 13:21 0:00 grep --color=auto -e Send
|
102
|
+
```
|
103
|
+
■サービス起動
|
104
|
+
```
|
105
|
+
[root@localhost ~]# systemctl start Send
|
106
|
+
[root@localhost ~]# systemctl status Send
|
107
|
+
● Send.service - Send daemon
|
108
|
+
Loaded: loaded (/etc/systemd/system/Send.service; enabled; vendor preset: disabled)
|
109
|
+
Active: active (running) since 金 2017-12-22 13:26:01 JST; 2min 20s ago
|
110
|
+
Main PID: 4588 (Send.sh)
|
111
|
+
CGroup: /system.slice/Send.service
|
112
|
+
├─4588 /bin/bash /opt/Send.sh
|
113
|
+
└─4589 dotnet /opt/Send/Send.Service.dll
|
114
|
+
|
115
|
+
12月 22 13:26:01 localhost.localdomain systemd[1]: Started Send daemon.
|
116
|
+
12月 22 13:26:01 localhost.localdomain systemd[1]: Starting Send daemon...
|
117
|
+
[root@localhost ~]# ps aux | grep -e Send
|
118
|
+
root 4588 0.0 0.1 115252 1448 ? Ss 13:26 0:00 /bin/bash /opt/Send.sh
|
119
|
+
root 4589 0.2 4.5 2653236 50428 ? SLl 13:26 0:00 dotnet /opt/Send/Send.Service.dll
|
120
|
+
root 4612 0.0 0.0 112676 980 pts/3 R+ 13:31 0:00 grep --color=auto -e Send
|
66
121
|
```
|