Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Perl Daemon Calling a script

by roboticus (Chancellor)
on Jan 24, 2013 at 01:56 UTC ( #1015058=note: print w/replies, xml ) Need Help??

in reply to Perl Daemon Calling a script


A few notes in no particular order:

  • I'd suggest redirecting your output to a scratch file while debugging, just in case the daemonized and/or shell script emits some errors that might help you along. You can use /dev/null after you have it properly demonified.
  • Should you rewrite the shell script in perl? That depends: If the script is tiny and easy to convert, then I'd do so. If it's large it may not be worth the hassle. If you like, you might write a couple of chunks of it in perl, and call that from the shell script, and as you maintain it, you can suck more of the shell script into perl as makes sense. For example, I can never remember sed well enough to use it, so I just use perl for all my sed jobs.
  • It looks like you may be removing $PID_FILENAME too soon. It appears that when you do the "detach terminal" bit, after the fork, it'll get dropped. You might want to add your signal handler after you've achieved complete deemonification.

Note: Yes, the entire reason for this post was so I could write a couple goofy variations on the word 'daemon'. I had a couple other variations, but forgot 'em before I found a place to put 'em.


When your only tool is a hammer, all problems look like your thumb.

Replies are listed 'Best First'.
Re^2: Perl Daemon Calling a script
by perlology (Initiate) on Jan 24, 2013 at 12:11 UTC
    Thank you for the pragmatic approach. I am moving forth with those suggestions now.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1015058]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2018-05-27 20:16 GMT
Find Nodes?
    Voting Booth?