Skip to content

Instantly share code, notes, and snippets.

@jintao-zero
Created October 24, 2017 06:04
Show Gist options
  • Save jintao-zero/7f391b66475fcd7b135a4e968ab815b5 to your computer and use it in GitHub Desktop.
Save jintao-zero/7f391b66475fcd7b135a4e968ab815b5 to your computer and use it in GitHub Desktop.
check some process is running, if not start it
#!/usr/bin/env bash
# get dir
fullpath=$(readlink -f "$0")
path=$(dirname "$fullpath")
exec=$path/l2-proxy
#`ps -ef | grep "/root/l2/hsl-level2hq/client/"`
checkresult=$(ps -e -o cmd | grep -v "grep" | grep "$exec" | wc -l)
if [ $checkresult -eq 1 ];
then
: #do nothing
#echo $path/
else
echo $(date) $exec no runing, now start it
nohup $exec 1>>$path/1.out 2>&1 &
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment