【发布时间】:2020-04-04 05:20:55
【问题描述】:
我有一个脚本必须在后台运行另一个脚本:
#!/bin/bash
( cd /var/lib/docker/volumes/hostcontrol-pipe/_data/ && ./run-pipe.sh ) &
首先它改变目录并运行一个脚本。 run-pipe.sh 在其目录中创建命名管道。 我有一个 monit 配置文件来监控这个脚本,如果它没有运行就重新启动它:
check program check-pipe with path /bin/bash -c "echo 'ping' > /var/lib/docker/volumes/hostcontrol-pipe/_data/host-pipe" with timeout 1 seconds
if status != 0 then
restart
start program = "/var/lib/docker/volumes/hostcontrol-pipe/_data/monit.sh"
第一行检查脚本正在运行写入其管道,它可以工作。 “启动程序”行不起作用 - 脚本不运行并且它在“ps ax”中不存在。但我在“sudo monit -vI”中看到:
'check-pipe' start: '/var/lib/docker/volumes/hostcontrol-pipe/_data/monit.sh'
'check-pipe' started
'check-pipe' program started
那么,为什么 monit 不能运行脚本呢?我尝试了不同的变体,但无法运行它。我可以在不更改目录 (cd) 的情况下运行它,但这是必要的。
【问题讨论】: