Skip to content

Instantly share code, notes, and snippets.

@peco8
Last active August 9, 2017 22:46
Show Gist options
  • Save peco8/8de090a51a547a741b596bf622bf639e to your computer and use it in GitHub Desktop.
Save peco8/8de090a51a547a741b596bf622bf639e to your computer and use it in GitHub Desktop.
ps_check.sh
```
#!/bin/bash
ps_out=`ps -ef | grep $1 | grep -v 'grep' | grep -v $0`
result=$(echo $ps_out | grep "$1")
if [[ "$result" != "" ]];then
echo "Running"
else
echo "Not Running"
fi
```
```
20:10 $ checkRunningProcess.sh proxy.py
Running
20:12 $ checkRunningProcess.sh abcdef
Not Running
```
###########################
```
!/bin/bash
CHECK=$0
SERVICE=$1
DATE=`date`
OUTPUT=$(ps aux | grep -v grep | grep -v $CHECK |grep $1)
echo $OUTPUT
if [ "${#OUTPUT}" -gt 0 ] ;
then echo "$DATE: $SERVICE service running, everything is fine"
else echo "$DATE: $SERVICE is not running"
fi
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment