

# poll if the process is died, if got died then restart it. #when execute this shell script, if the process is running,kill it firstly Process Monitor HOWTO for Linux Al Dev (Alavoor Vasudevan) v3. Test_process="ython.*nohup_restart_test_py" # $1->process_name by grep, $2->python directoryĮcho "$(TIMESTAMP) $3 got down, now I will restart it" | tee -a $log_fileĮcho "$(TIMESTAMP) $3 restart successfully" | tee -a $log_fileĮcho "$(TIMESTAMP) $3 is running, no need to restart" Ps -ef | grep "$1" | awk '' | xargs kill -9 #restart scrape news process if the process exited accidentallyĮcho "$(TIMESTAMP) $1 is running, T'm going to kill it" The script basically checks if the desired service is available or not. It is to not kill the shell's own grep program, of course, you would normally add grep -v grep to exclude the shell's own grep, but I think it is more convenient to add #!/bin/bash How to monitor, automatically restart, and report the current status of a Linux service To monitor a service, restart it automatically, and push the current status to PRTG with HTTP, use the script below. How do I use a simple bash script to restart service or a program if not running, and monitor this service by a cron job in Linux. The following shell has test_process="ython.*nohup_restart_test_py" The reason for adding yth.
