linux - 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 here
RHEL 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
解决方案
我在发布后立即找到了答案 - 所以如果其他人好奇,我们必须添加这个参数: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
推荐阅读
- sql - Oracle SQL:如何使用 CHECK 约束不允许重叠预订日期
- java - 使用比较器根据 ArrayList 对数组进行排序
- reactjs - 使用反应过滤对象时出现问题
- session - Laravel 保存用户获取重定向路由
- docker - 在主机上运行 docker 命令
- python - 我正在尝试制作素数和合数游戏,即使您输入错误的答案,它也总是会打印“正确答案”
- ios - ImageLoaderMachO::doInitialization 后如何修复 ios 应用程序启动崩溃
- laravel - 如何在 laravel 资源 api 中以自定义格式显示数据
- python - 检测具有混合变量类型的几乎重复的行
- java - 无法使用 WorkBook 工厂打开受西里尔密码保护的 xslx 文件