简体   繁体   中英

Check if bash script (run by cron job) is running in Openshift

I try ps aux and ps and pgrep myprocess and pidof myprocess but all say my script is not running (while my script is actually running). I check these command with ssh.

Do you have any idea?

If you use ssh to have to watch the pid you are actually sending

So run pgrep like this, ssh returns the exit status from the command you run:

ssh myserver 'pgrep -u username scriptname' 
[ $? -eq 0 ] && echo 'Running' || echo "Not running"

username is the name of the user that started the process ex: root, daniyal, santa, or maybe jim scriptname the actual name of the script file ex: myscript.sh, fixit.sh, or maybe foo.sh

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM