Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Daemon, log4perl & stderr/stdout

by saberworks (Curate)
on May 30, 2008 at 16:31 UTC ( [id://689270]=note: print w/replies, xml ) Need Help??


in reply to Daemon, log4perl & stderr/stdout

Just an update on how I got step one working -- piping standard error and standard out to their own files on a per-job basis (so each job gets a separate set of log files). The suggestions for just reopening STDERR and STDOUT weren't working because I was opening and then closing them inside a while loop, and when I closed them, and then later reopened, they were getting new fileno() (as a previous poster mentioned, I should check that the number is 2). Instead of closing them at the end of the loop, I just reopened them back to /dev/null and everything worked fine. Here is some psuedocode that may make it easier to understand:
while(my $job = get_next_job()) { my $run_path = $job->get_run_path(); open STDERR, '>', "$run_path/stderr.txt" or die; open STDOUT, '>', "$run_path/stdout.txt" or die; $job->run(); open STDERR, '>', '/dev/null'; open STDOUT, '>', '/dev/null'; # Do some other job cleanup/notification stuff that may # output to STDERR/STDOUT but I don't want in the # individual job log files do_some_other_stuff_before_going_to_next_job(); }
Thanks everyone for the help.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://689270]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2024-04-24 01:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found