Created
September 26, 2014 12:48
-
-
Save kanazux/fc449e46427f60b9e493 to your computer and use it in GitHub Desktop.
kill cat process opened by syslog
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/bash | |
PKILL=`which pkill` | |
PGREP=`which pgrep` | |
DATE=`which date` | |
WC=`which wc` | |
getCat=`$PGREP -fl "cat -u" | $WC -l` | |
if [ $getCat -gt 5 ]; then | |
echo "`$DATE '+%h %d %T'` | WF_CleanGargage | More then 5 process running" >> /var/log/rotate.log | |
$PKILL -f "cat -u" | |
echo "`$DATE '+%h %d %T'` | WF_CleanGarbage | Killed $getCat Process" >> /var/log/rotate.log | |
fi | |
getCatAgain=`$PGREP -fl "cat -u" | $WC -l` | |
if [ $getCatAgain -gt 5 ]; then | |
echo "`$DATE '+%h %d %T'` | WF_CleanGarbage | Still have process running" >> /var/log/rotate.log | |
else | |
echo "`$DATE '+%h %d %T'` | WF_CleanGarbage | No more process running" >> /var/log/rotate.log | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment