process_check_script_for_cron
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| process_check_script_for_cron [2011/11/11 16:37] – k2patel | process_check_script_for_cron [2020/08/10 02:35] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 3: | Line 3: | ||
| This script will check process if it is not running | This script will check process if it is not running | ||
| and will start the process if not running. | and will start the process if not running. | ||
| + | |||
| + | ==== First ==== | ||
| <code bash | proc_script.sh> | <code bash | proc_script.sh> | ||
| Line 17: | Line 19: | ||
| fi | fi | ||
| </ | </ | ||
| + | |||
| + | ==== Second ==== | ||
| I made some changes as there is actually no need to equality check: | I made some changes as there is actually no need to equality check: | ||
| + | |||
| <code bash | proc_scriptjt.sh> | <code bash | proc_scriptjt.sh> | ||
| Line 32: | Line 37: | ||
| echo “Process Running - do nothing” | echo “Process Running - do nothing” | ||
| fi | fi | ||
| + | </ | ||
| + | |||
| + | ==== Third ==== | ||
| + | |||
| + | |||
| + | This is in python :) | ||
| + | |||
| + | <code python> | ||
| + | # | ||
| + | # -*- coding: utf-8 -*- | ||
| + | """ | ||
| + | Created on Thu Aug 4 14:46:52 2011 | ||
| + | |||
| + | @author: k2patel@hotmail.com | ||
| + | """ | ||
| + | |||
| + | import subprocess | ||
| + | import psutil | ||
| + | |||
| + | # reset running variable | ||
| + | running = 0 | ||
| + | |||
| + | |||
| + | for proc in psutil.get_process_list(): | ||
| + | if proc.username == ' | ||
| + | ## Actual Command | ||
| + | ## ssh -f -N -i / | ||
| + | ## Actual CMDLINE output | ||
| + | ## ssh-f-N-i/ | ||
| + | if proc.cmdline == ([' | ||
| + | running = 1 | ||
| + | | ||
| + | | ||
| + | if running is 1: | ||
| + | print " | ||
| + | else: | ||
| + | subprocess.call([' | ||
| + | | ||
| </ | </ | ||
process_check_script_for_cron.1321029460.txt.gz · Last modified: 2020/08/10 02:29 (external edit)
