User Tools

Site Tools


process_check_script_for_cron

This is an old revision of the document!


Process Check script for cron

This script will check process if it is not running and will start the process if not running.

| proc_script.sh
#!/bin/bash
# check process
ps -ef | grep -v grep | grep 2200:localhost:22
# if not found - equals to 1, start it
if [ $? -eq 1 ]
then
ssh -f -N -R 2200:localhost:22 k2patel@71.245.248.138
echo "Process not running - Started"
else
echo “Process Running - do nothing”
fi

I made some changes as there is actually no need to equality check:

| proc_scriptjt.sh
#!/bin/bash
# check process
 
# if can parse the statement and watch the exit code
if ps -ef | grep -v grep | grep 2200:localhost:22
then
ssh -f -N -R 2200:localhost:22 k2patel@71.245.248.138
echo "Process not running - Started"
else
echo “Process Running - do nothing”
fi
process_check_script_for_cron.1244127618.txt.gz · Last modified: 2020/08/10 02:29 (external edit)