in reply to Generic Daemon Use

This worked for me. I used 'apt' instead:

#!/usr/bin/perl use strict; use warnings; use Daemon::Generic; my $sleeptime = 1 newdaemon( progname => 'apt', pidfile => '/var/run/apt.conf.pid', configfile => '/etc/apt.conf', ); sub gd_preconfig { my ($self) = @_; open(CONFIG, "</etc/apt.conf") while <CONFIG>; close(CONFIG); return (); } sub gd_run { while (1) { sleep($sleeptime); print scalar(localtime(time))."\n"; } }
Note: I didn't use foreground. It went into an infinite loop. Use: perl myscript.pl start, then perl myscript.pl check. It'll give a pid number.

Replies are listed 'Best First'.
Re^2: Generic Daemon Use
by f00li5h (Chaplain) on Feb 03, 2007 at 13:54 UTC

    I would have thought you'd want your daemon to run in an infinite loop (while waiting for Unix signals/sockets/alarms)

    Otherwise you've just got a normal perl script ...

    @_=qw; ask f00li5h to appear and remain for a moment of pretend better than a lifetime;;s;;@_[map hex,split'',B204316D8C2A4516DE];;y/05/os/&print;