[Chicago-talk] writing a log with Cron, Daemons, Perl

Steven Lembark lembark at jeeves.wrkhors.com
Thu Sep 11 07:51:56 CDT 2003



--On Friday, September 05, 2003 09:50:37 -0500 Jay Strauss <me at heyjay.com> 
wrote:

> I'm using Net::Server::Daemonize qw(daemonize) to turn my program into a
> daemon.
>
> sometimes I start this program from the command line, some times via cron.
> I'd like to have a log file that contains everything that would normally
> go to STDERR plus all the messages my program spits out.
>
> I'm running into a couple of problems:
>
> 1) how do I get stuff into my log file without closing the file handle?  I
> tried $|++;  For example:


unless( -t )
{
    use Basename;

    my $base = (fileparse $0, '\..*')[0];
    open STDOUT, '>', "$logdir/$base.out";
    open STDERR, '>', "$logdir/$base.err";

    select STDERR;
    $| = 1;

    select STDOUT;
}


-- 
Steven Lembark                                            2930 W. Palmer
Workhorse Computing                                    Chicago, IL 60647
                                                         +1 888 910 1206



More information about the Chicago-talk mailing list