質問編集履歴

1

内容追記

2017/12/22 04:42

投稿

programmer010
programmer010

スコア14

test CHANGED
File without changes
test CHANGED
@@ -129,3 +129,113 @@
129
129
  root 4172 0.0 0.0 112676 980 pts/3 R+ 11:19 0:00 grep --color=auto -e Server -e postgres
130
130
 
131
131
  ```
132
+
133
+
134
+
135
+ <追記>
136
+
137
+ ちなみに、同じようなスクリプトをサービス起動するとプロセスは起動したままになります。
138
+
139
+
140
+
141
+ ###対象ファイル
142
+
143
+ ■スクリプト(/opt/Send.sh)
144
+
145
+ ```
146
+
147
+ #!/bin/bash
148
+
149
+ dotnet /opt/Send/Send.Service.dll
150
+
151
+
152
+
153
+ ```
154
+
155
+ ■.serviceファイル(/etc/systemd/system/Send.service)
156
+
157
+ ```
158
+
159
+ [Unit]
160
+
161
+ Description = Send daemon
162
+
163
+ After = Server.service
164
+
165
+
166
+
167
+ [Service]
168
+
169
+ ExecStart = /opt/Send.sh
170
+
171
+ Restart = no
172
+
173
+ Type = simple
174
+
175
+ RemainAfterExit = yes
176
+
177
+
178
+
179
+ [Install]
180
+
181
+ WantedBy = multi-user.target
182
+
183
+ ```
184
+
185
+
186
+
187
+ ###実行結果
188
+
189
+ ■スクリプト実行
190
+
191
+ ```
192
+
193
+ [root@localhost ~]# /opt/Send.sh
194
+
195
+ [root@localhost ~]# ps aux | grep -e Send
196
+
197
+ root 4552 0.0 0.1 113128 1188 pts/2 S+ 13:20 0:00 /bin/bash /opt/Send.sh
198
+
199
+ root 4553 0.5 4.6 2653372 51032 pts/2 SLl+ 13:20 0:00 dotnet /opt/Send/Send.Service.dll
200
+
201
+ root 4567 0.0 0.0 112676 980 pts/3 R+ 13:21 0:00 grep --color=auto -e Send
202
+
203
+ ```
204
+
205
+ ■サービス起動
206
+
207
+ ```
208
+
209
+ [root@localhost ~]# systemctl start Send
210
+
211
+ [root@localhost ~]# systemctl status Send
212
+
213
+ ● Send.service - Send daemon
214
+
215
+ Loaded: loaded (/etc/systemd/system/Send.service; enabled; vendor preset: disabled)
216
+
217
+ Active: active (running) since 金 2017-12-22 13:26:01 JST; 2min 20s ago
218
+
219
+ Main PID: 4588 (Send.sh)
220
+
221
+ CGroup: /system.slice/Send.service
222
+
223
+ ├─4588 /bin/bash /opt/Send.sh
224
+
225
+ └─4589 dotnet /opt/Send/Send.Service.dll
226
+
227
+
228
+
229
+ 12月 22 13:26:01 localhost.localdomain systemd[1]: Started Send daemon.
230
+
231
+ 12月 22 13:26:01 localhost.localdomain systemd[1]: Starting Send daemon...
232
+
233
+ [root@localhost ~]# ps aux | grep -e Send
234
+
235
+ root 4588 0.0 0.1 115252 1448 ? Ss 13:26 0:00 /bin/bash /opt/Send.sh
236
+
237
+ root 4589 0.2 4.5 2653236 50428 ? SLl 13:26 0:00 dotnet /opt/Send/Send.Service.dll
238
+
239
+ root 4612 0.0 0.0 112676 980 pts/3 R+ 13:31 0:00 grep --color=auto -e Send
240
+
241
+ ```