Bash 是否可以在服务内部运行shell命令
在Bash 是否可以在服务内部运行shell命令,bash,service,systemd,rhel,systemctl,Bash,Service,Systemd,Rhel,Systemctl,在/etc/systemd/system下,我们有服务-cc\u check.service 在服务中,我们激活脚本-/home/cc\u start\u daemon.sh 如下所示 ExecStart=/home/cc_start_daemon.sh 是否可以在服务内部添加shell命令-bash/home/second\u try.shas [Service] Restart=on-failure StartLimitInterval=5min StartLimitBurst=4 Lim
/etc/systemd/system
下,我们有服务-cc\u check.service
在服务中,我们激活脚本-/home/cc\u start\u daemon.sh
如下所示
ExecStart=/home/cc_start_daemon.sh
是否可以在服务内部添加shell命令-bash/home/second\u try.sh
as
[Service]
Restart=on-failure
StartLimitInterval=5min
StartLimitBurst=4
LimitMEMLOCK=infinity
LimitNOFILE=65535
Type=simple
ExecStart=/home/cc_start_daemon.sh
bash /home/second_try.sh
[Install]
WantedBy=multi-user.target
目标是在-
/home/cc\u start\u daemon.sh
之后运行另一个脚本,该脚本不是有效的SystemD语法,因此我只需要创建一个新脚本来同时运行这两个脚本
#!/bin/bash
/home/cc_start_daemon.sh
/home/second_try.sh