[clug] COTH -- (Another) Command of the hour
Andrew Janke
a.janke at gmail.com
Thu Feb 12 04:22:12 GMT 2009
pidof
ie:
$ pidof firefox
119232
I "found" this while writing a quick script that I can call from cron
to start workrave in case I forget to (my home dir is NFS mounted
across a bunch of machines and I run gnome):
#! /bin/sh
HOSTNAME=`hostname`
# exit if on wrong host
if [ "$HOSTNAME" != "ben" ]
then
exit 0
fi
# exit if not logged in
if ! killall -s 0 -u rotor gnome-session > /dev/null 2>&1
then
exit 0
fi
# check if workrave is going
if ! pidof workrave > /dev/null
then
echo "Starting workrave"
workrave &
fi
Note that I _also_ discovered that pidof is apparently the same as
"killall -s 0" which in turn a signal of 0 means "are you able to be
killed" or something like that.
ah, two new things in one day. My head is full.
a
More information about the linux
mailing list