Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash 是否可以在服务内部运行shell命令_Bash_Service_Systemd_Rhel_Systemctl - Fatal编程技术网

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