Created
March 24, 2016 10:10
-
-
Save wehappyfew/720cd12798bb066f7c87 to your computer and use it in GitHub Desktop.
Bash script to kill any firefox instance that runs for more than 10 minutes [runs every 1 minute]
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
# Notice: to run it, create a cronjob with the line below | |
# */1 * * * * root sh /path/to/file/kill_stuck_firefox.sh | |
#!/bin/bash | |
# This script will kill process which running more than 10 minutes | |
# egrep: the selected process; grep: hours | |
PIDS="`ps eaxo etime,pid,comm | egrep "firefox" | grep " [1-5][0-9]:" | awk '{print $2}'`" | |
# Kill the process | |
echo "Killing firefox processes running more than 10 minutes..." | |
for i in ${PIDS}; do { echo "Killing $i"; sudo kill -9 $i; }; done; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment