这是我的代码:
#!/bin/bash
ps cax | grep testing > /dev/null
while [ 1 ]
do
if [ $? -eq 0 ]; then
echo "Process is running."
sleep 10
else
nohup ./testing.sh &
sleep 10
fi
done我以nohup ./script.sh &的身份运行它
上面写着nohup: failed to run command './script.sh': No such file or directory
怎么啦?
发布于 2015-10-13 08:29:15
对于Linux上每个新创建的脚本,首先应该更改权限,因为您可以通过以下方法查看权限详细信息:
ls -lah以下内容可能对您有所帮助:
#!/bin/bash
while [ 1 ];
do
date=`date`
pid=`ps -ef | grep "your process" | grep -v grep | awk -F' ' '{print $2}'`
if [[ -n $pid ]]; then
echo "$date - processID $pid is running."
else
echo "$date - the process is not running"
# script to restart your process
say: start the process
fi
sleep 5m
done发布于 2015-08-20 09:53:49
发出命令的目录中根本不存在文件script.sh。
如果它确实存在且不可执行,您将得到:
‘`nohup:未能运行命令’./script.sh‘:权限被拒绝
发布于 2015-08-20 05:10:53
确保将脚本保存为script.sh,并将执行的nohup.script.sh保存在与script.sh所在的目录相同的位置。还可以通过以下方式为script.sh提供可执行权限
chmod 776 script.sh或
nohup ./script.sh &以形式运行
nohup sh ./script.sh &https://stackoverflow.com/questions/32109448
复制相似问题