Created
September 24, 2012 12:26
-
-
Save kacinskas/3775701 to your computer and use it in GitHub Desktop.
LINUX: get PID
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
SERVICE='EldesDaemon' | |
FILE='/usr/local/sbin/eldes/EldesDaemon.pid' | |
if ps ax | grep -v grep | grep $SERVICE > /dev/null | |
then | |
#PIDID=$(ps ax | grep -v grep | grep $SERVICE | awk '{print $1}') | |
#echo "$SERVICE service running, everything is fine" | |
#echo "pid = $PIDID" | |
#echo $PIDID > $FILE | |
if [ -f $FILE ]; | |
then | |
echo "File $FILE exists" | |
while read line | |
do | |
PIDID=${line%,*} | |
echo $PIDID | |
done < $FILE | |
kill -9 $PIDID | |
else | |
echo "File $FILE does not exist" | |
fi | |
else | |
echo "$SERVICE is not running" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi!
Looks like bugs/mistakes migrates from one user to other. Does no one aware about pidof? In 99,999% cases I see:
ps x | grep ...
. Are you aware about pidof?::