Bash Script not executing command
I have a bash script that is supposed to check for a running instance of a program and if its not running execute a command (echo for testing purposes). The problem is, that bash isn't executing the command even though it works when I copy/paste the command directly to the command line. I imagine my issue is simple and caused by my naivety with the script language.
The line in question:
ps -ef | grep -v grep | grep $SCRIPT > /dev/null || echo "`date` - $0 : $SCRIPT stopped. Restarting..."
If I paste it to the command line it works perfect, but when I run my script nothing happens. Suggestions?
EDIT: I believe I've resolved the issue. The script that is run to check the queue_reader.sh
script I foolishly named check_queue_reader.sh
" so the ps -ef
command was finding itself preventing the ||
from executing.
See edit on original post.
The script I was running was called "check_queue_reader.sh" and was using grep to search ps -ef
for "queue_reader.sh". This caused the script to locate itself thus failing the check when it got to ||
上一篇: 在bash脚本中运行nohup时出错
下一篇: Bash脚本不执行命令