I'm working on writing a shell script that logs out whenever I have a firefox process running during certain times of the day (1 am - 8 am). I'll put it in crontab when it runs properly unless someone knows of a different and better way to do this. Here it is so far.
if ps ax | grep firefox-3.6.3
then
echo hi
/usr/bin/gnome-session-save --kill --silent
exit 0
fi
Its not working yet cause grep isn't filtering the way I need it to. This is what I get when firefox is running.
ps ax | grep firefox-3.6.3
1859 ? S 0:00 /bin/sh /usr/lib/firefox-3.6.3/firefox
1864 ? S 0:00 /bin/sh /usr/lib/firefox-3.6.3/run-mozilla.sh /usr/lib/firefox-3.6.3/firefox-bin
1868 ? Sl 1:45 /usr/lib/firefox-3.6.3/firefox-bin
3374 pts/0 S+ 0:00 grep --colour=auto firefox-3.6.3
This is what I get when firefox is not running.
ps ax | grep firefox-3.6.3
3374 pts/0 S+ 0:00 grep --colour=auto firefox-3.6.3
I need it to ignore the grep filtering process.