Skip to content

Instantly share code, notes, and snippets.

@wdalmut
Created June 19, 2013 07:45
Show Gist options
  • Select an option

  • Save wdalmut/5812375 to your computer and use it in GitHub Desktop.

Select an option

Save wdalmut/5812375 to your computer and use it in GitHub Desktop.
Just a simple shell watchdog...
#!/bin/bash
PS=/bin/ps
GREP=/bin/grep
PROCESS_NAME=wftpserver
START="/etc/init.d/wftpserver start"
NOP=/bin/true
LOGGER=/usr/bin/logger
$PS -ef | $GREP -v grep | $GREP $PROCESS_NAME > /dev/null 2>&1
case "$?" in
0)
#Its running
$LOGGER "$PROCESS_NAME is RUNNING OK. Relax..."
$NOP
;;
1)
$LOGGER "$PROCESS_NAME is NOT RUNNING. Starting $PROCESS_NAME and sending notices."
$START
esac
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment