Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > get messages from background task to log file (start-stop-daemon with perl script stderr)

Reply
Thread Tools

get messages from background task to log file (start-stop-daemon with perl script stderr)

 
 
Grischa Schuering
Guest
Posts: n/a
 
      09-29-2003
Hello,

I have a perl daemon running using the start-stop-daemon in background mode.
Now I would like to get the mnessages, that were originally send on STDIN,
STDOUT, STDERR to a file.

Using start-stop-daemon --exec $DAEMON --background >$2 file.log is not
working. No wonder, sonce a backround task should not send any information
to STDIN and so on.

What is the correct command to get the mesages to file or syslog
(whatever)???



 
Reply With Quote
 
 
 
 
David Efflandt
Guest
Posts: n/a
 
      09-29-2003
On Mon, 29 Sep 2003 23:51:22 +0200, Grischa Schuering <> wrote:
> Hello,
>
> I have a perl daemon running using the start-stop-daemon in background mode.
> Now I would like to get the mnessages, that were originally send on STDIN,
> STDOUT, STDERR to a file.
>
> Using start-stop-daemon --exec $DAEMON --background >$2 file.log is not
> working. No wonder, sonce a backround task should not send any information
> to STDIN and so on.
>
> What is the correct command to get the mesages to file or syslog
> (whatever)???


Look for SyS::Syslog module.

Working example:

#!/usr/bin/perl -w
# Name of this script
if ($0 =~ m|/([^/]+)$|) { $id = $1; } else { $id = $0; }
use Sys::Syslog qw(EFAULT setlogsock);
setlogsock 'unix' || die "Can't setlogsock";
sub mylog {
my $msg = shift;
chomp $msg; # if needed
syslog('info',"$id\[$$]:$msg"); closelog();
}
mylog("I'm running");


The script was called 'logme', result in syslog:

Sep 29 18:48:27 efflandt logme[31707]: I'm running

--
David Efflandt - All spam ignored http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ calling perl script - Not able to get the stack arguments pushedrom XPUSH in perl script Yogi Perl Misc 1 09-13-2012 11:30 AM
Accessing ant task name when running a task teggy Java 0 05-29-2007 02:20 PM
Maven using ANT plugin for SCP task : Embedded error: Could not create task or type of type: scp. krabhi Java 1 08-09-2006 04:19 PM
Re: Problem in ant replace task and replaceregexp task to update xml Victor Java 0 09-01-2004 03:58 AM
Perl Help - Windows Perl script accessing a Unix perl Script dpackwood Perl 3 09-30-2003 02:56 AM



Advertisments