Skip to content

Instantly share code, notes, and snippets.

@yashprit
Created July 10, 2014 09:08
Show Gist options
  • Save yashprit/7661b25904c93d53acff to your computer and use it in GitHub Desktop.
Save yashprit/7661b25904c93d53acff to your computer and use it in GitHub Desktop.
Monitor processing running on system, with single argument as process
#!/bin/bash
if [ $EUID != 0 ]
then
echo "Please run as root"
exit
fi
if [ "$1" == "" ]
then
echo "No process name provided"
exit
fi
check_process() {
echo "`date +%T` : begin checking.... $1"
[ `pgrep -n $1` ] && return 1 || return 0
}
while [ 1 ]; do
check_process "$1"
[ $? -eq 0 ] && echo "$ts: not running, restarting..." && `$1 -i > /dev/null`
sleep 200
done
@yashprit
Copy link
Author

usage, pass single parameter after shell, e.g sudo bash ./process_monitor.sh dropbox

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment