首页 > 解决方案 > Custom Script started in bootup of Red Hat has child processes killed

问题描述

We are starting an application in the bootup of a Red Hat Linux (enter code hereRHEL 7) server but the child processes that are started from this script are killed once the script finishes. The Bash script is a very simple script: It starts the app on this server (01) which will spawn several child processes, and then it starts the app on 2 other servers via ssh. The processes on the remote servers are fine and do not get killed.
I can see the app is running for a few minutes while the script is starting the apps on those remote servers. I can list the processes and i can open the UI of the app. However, once the script finishes - boom, the processes are killed hard. The process ids just disappear.

The start script is started this way: cat /etc/systemd/system/gis.service

[Unit]
Description=Sterling Integrator App startup
After=default.target

[Service]
Type=oneshot
ExecStart=/s10/sterling/uwwbin/startup_gis_nodes_master.sh
#ExecStart=/s10/sterling/strace-script.sh
User=gisuser
Group=gisuser

[Install]
WantedBy=default.target

Any ideas? Thanks

标签: linuxredhat

解决方案


我在发布后立即找到了答案 - 所以如果其他人好奇,我们必须添加这个参数:RemainAfterExit=yes

所以整个脚本是:

cat /etc/systemd/system/gis.service
[Unit]
Description=Sterling Integrator App startup
After=default.target

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/s10/sterling/uwwbin/startup_gis_nodes_master.sh
User=gisuser
Group=gisuser

[Install]
WantedBy=default.target

推荐阅读