I just wrote a quick hack to check whether a daemon is running when it starts:
# quit if already running if (-e "/var/run/process_email.pid") { my $pid=9999999999; `cat /var/run/process_email.pid` =~ /(\d+)/ and $pid=$1; exit if (`ps aux|awk '{print \$2}' |grep $pid`); }
but I can't help thinking that there must be a more "perlish" way of doing this.
I did a quick search on CPAN, but I couldn't find a relevant module. Perhaps I was searching on the wrong term?
Anyone know if there's a standard way of doing this? Or is my hack similar to how others have approached this problem?
cLive ;-)
In reply to checking if daemon is running by cLive ;-)
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |