in reply to Generic Daemon Use
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.#!/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"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Generic Daemon Use
by f00li5h (Chaplain) on Feb 03, 2007 at 13:54 UTC |