[Voyage-linux] log the stdout of a process started by start-stop-daemon
Toni Castelli
(spam-protected)
Tue Apr 3 16:55:08 HKT 2012
Hi Kevin,
Thanks for suggestion, I tried it but it also didn't work. For some reason,
I'm not able to redirect the output of startup daemons (even modyfing
another standard daemons like dns or dchp). At starup, the script ignores
whatever comes after the pipe or the redirect argument. I'm not sure if that
could be something related to my voyage version or something else.
I will continue trying things (already tried umount /var/log but the file
isn't there..) but I'm getting out of ideas
-----Mensaje original-----
From: Kevin Wang
Sent: Friday, March 30, 2012 8:25 AM
To: Toni Castelli
Cc: voyage-linux at voyage.hk
Subject: Re: [Voyage-linux] log the stdout of a process started by
start-stop-daemon
>From Toni Castelli
> I've tried using sleep 60 and the problem continues so I guess it's not
> something related with /var/log
> also I've tried to use another directory to create the log file(not a
> tmpfs) and the behavior is the same, after rebooting the log file is never
> generated, but when I start it manually in bash it works perfectly.
>
> maybe I'm wrong, but how could I use logger to save the stderr and stdout
> of the start-stop-daemon?
logger just talks to the running syslogd.
I just confirmed that you can do the following:
$DAEMON 2>&1 | logger -i
The nice part is that you are NOT writing to a file; you're talking to
the logging daemon. So the whole writing to disk thing becomes syslog's
problem, not yours. Also everything gets datestamped.
- Kevin
> -----Mensaje original-----
> From: Kevin Wang
> Sent: Thursday, March 29, 2012 5:32 PM
> To: Toni Castelli
> Cc: Francisco Jos? S?nchez ; voyage-linux at voyage.hk
> Subject: Re: [Voyage-linux] log the stdout of a process started by
> start-stop-daemon
>
> >From Toni Castelli
> >Hello Francisco,
> >Thanks for your answer, I ve tried to include $mountkernfs in the
> >required
> >modules of the script, but it didn t work.
> >I m not sure why the touch command doesn t work because i set remountrw
> >just
> >before the command but the file is not created.
> >
> >I ve also tried using another directory that is not tmpfs but the result
> >is the
> >same, it works when I start it manually but not after rebooting
>
> /var/log is a ramdisk(tmpfs). I don't know at what point during boot
> it becomes a ramdisk. You need to start your script afterwards, or use
> logger like I describe (if it has the -t flag)
>
> remountrw will not be needed, since /var/log is converted from flash to
> a ramdisk, and the ramdisk is always writable.
>
> as a brute force, would adding a "sleep 60" to the top of your script
> delay it enough to be after /var/log mounting? that at least would
> prove that the mounting of /var/log is the issue.
>
> - Kevin
>
> >(I ve set #!bin/bash at the beggining of the script)
> >
> >From: Francisco Jos S nchez
> >Sent: Tuesday, March 27, 2012 10:08 PM
> >To: Toni Castelli
> >Cc: voyage-linux at voyage.hk
> >Subject: Re: [Voyage-linux] log the stdout of a process started by
> >start-stop-daemon
> >
> >Ok Toni,
> >
> >I think that the problem is the moment executed script. Question is
> >mounted /
> >var/log?
> >
> >For depuration include into script a mount command before touch file log.
> >
> >PD: normaly, /var/log is mount tmpfs (/etc/init.d/mountkernfs). Is the
> >execution your script before or after mountkernfs?
> >
> >Best regards.
> >
> >
> >2012/3/27 Toni Castelli <acastelli at keonn.com>
> >
> > Yes, sorry thats a typo, I actually use what you wrote
> >logFile=/var/log/
> > test.log
> >
> > When I start the script manually /etc/init.d/script start it runs
> > my
> > program ok and generates the proper log file, the problem is that
> >after
> > rebooting, my program starts automatically but the no log file is
> >created.
> >
> >
> > From: Francisco Jos S nchez
> > Sent: Tuesday, March 27, 2012 6:13 PM
> > To: Toni Castelli
> > Cc: voyage-linux at voyage.hk
> > Subject: Re: [Voyage-linux] log the stdout of a process started by
> > start-stop-daemon
> >
> > Hello Toni,
> >
> > 2012/3/27 Toni Castelli <acastelli at keonn.com>
> >
> > Hello, I m having some trouble trying to log the stdout and the
> > stderror generated by an application when it is started by an
> >init.d
> > script.
> >
> > What im trying to run is something like this:
> >
> > $logFile=/var/log/test.log
> >
> >
> > is wrong variable assignation (really is a error in your script o is
> > a
> > error the transcription email?)
> >
> >
> > logFile=/var/log/test.log
> >
> >
> >
> >
> >
> >
> > if [ ! "$logFile" == "" ]; then
> > touch $logFile || exit 2
> >
> > start-stop-daemon --start --make-pidfile --pidfile
> > $PIDFILE --exec $DAEMON -- $DAEMON_ARGS >> $logFile 2>&1 &
> > else ....
> >
> >
> > when you verify exists a file, use param -f . Example
> >
> >
> > if [ -f $logFile ]; then
> >
> > <code true>
> >
> > else
> >
> > <code false>
> >
> > fi
> >
> > or this other example
> >
> > if [ ! -f $logFile ]; then
> >
> > <code false condition>
> >
> > else
> >
> > <code true condition>
> >
> > fi
> >
> >
> >
> > but I don't know what yo want to do.
> >
> >
> >
> > when I try to run the script from bash it works perfectly, but
> >when it
> > runs after a reboot, the log file isn t generated. I m suspecting
> >it
> > could be a matter of mounting the file system after starting my
> >script,
> > but I ve checked the execution number and its the last one it
> >shares
> > the number with some other processes). Anyone can guess what s
> >wrong
> > with the code?
> >
> >
> > best regards.
> >
> > PD: Excuse me English language, but spanish user ;-)
> >
> >
> >
> > _______________________________________________
> > Voyage-linux mailing list
> > Voyage-linux at list.voyage.hk
> > http://list.voyage.hk/mailman/listinfo/voyage-linux
> >
> >
> >
> >
> > _______________________________________________
> > Voyage-linux mailing list
> > Voyage-linux at list.voyage.hk
> > http://list.voyage.hk/mailman/listinfo/voyage-linux
> >
> >
> >
>
> >_______________________________________________
> >Voyage-linux mailing list
> >Voyage-linux at list.voyage.hk
> >http://list.voyage.hk/mailman/listinfo/voyage-linux
>
>
> _______________________________________________
> Voyage-linux mailing list
> Voyage-linux at list.voyage.hk
> http://list.voyage.hk/mailman/listinfo/voyage-linux
More information about the Voyage-linux
mailing list