Skip to content

Instantly share code, notes, and snippets.

@kanazux
Created September 26, 2014 12:48
Show Gist options
  • Save kanazux/fc449e46427f60b9e493 to your computer and use it in GitHub Desktop.
Save kanazux/fc449e46427f60b9e493 to your computer and use it in GitHub Desktop.
kill cat process opened by syslog
#!/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