Skip to content

Instantly share code, notes, and snippets.

@QAutomatron
Created July 4, 2016 12:57
Show Gist options
  • Save QAutomatron/41b4d59b8d1e9db0d0d037d05ff48bff to your computer and use it in GitHub Desktop.
Save QAutomatron/41b4d59b8d1e9db0d0d037d05ff48bff to your computer and use it in GitHub Desktop.
Kill old chromedriver, chrome. Older than 10 min
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
# remove chrome older than 10 minutes
* * * * * root ps -eo pid,etime,command | grep -v grep | fgrep chromedriver | awk '{print $1":"$2}' | awk -F':' '{ if ($2 > 10 || $4) { print("kill process "$1" after "$2);system("kill -9 "$1);}}'
* * * * * root ps -eo pid,etime,command | grep -v grep | fgrep chrome | awk '{print $1":"$2}' | awk -F':' '{ if ($2 > 10 || $4) { print("kill process "$1" after "$2);system("kill -9 "$1);}}'
* * * * * root ps -eo pid,etime,command | grep -v grep | fgrep firefox | awk '{print $1":"$2}' | awk -F':' '{ if ($2 > 10 || $4) { print("kill process "$1" after "$2);system("kill -9 "$1);}}'
# */5 * * * * root se-cleaner.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment