Tuesday, November 27, 2012

Shell script scripts to restart firefox

My Firefox freezes up when I have too many flash videos loading at the same time. Wrote a simple script to restart Firefox every time this happens.
#!/bin/bash
#simple script to kill and restart firefox
#20th August 2007
#Writen by Danesh aka Danny
#http://thedaneshproject.com
#
#look for the firefox PID
PID=`ps -ef | grep firefox-bin | grep -v grep | awk ‘{print $2}’`
#locate firefox executable
FIRE=`which firefox`
#kill firefox
CMD=�kill -9 $PID�
`$CMD`
#pause for 2 seconds
`sleep 2`
#start firefox
CMD=�$FIRE�
`$CMD &`
#End of script
I will be adding more functionality to the script in the future. Once sure feature will be the ability to choose either to kill all running instances or just kill a specific instance.