Fedora/RH best practices for logging from init scripts...
|
Author |
Message |
|
|
Posted : Fri, 17 October 2008 22:12:34
Subject :
Fedora/RH best practices for logging from init scripts...
...prior to syslogd being up... I have an init script that runs before syslogd is up. I'd like it to be able to output to syslog so that after the system is fully booted, I can find some results from the script there. My OS's are fc1, fc4 and Centos 5 (all Red Hat variations). What is the best way for me to log output from an init script that runs before syslogd is up? For the life of me I can't find very good references to this on Google et al. Any pointers on this or refs to materials that discuss it would be great. Thanks in advance...
|
|
|
|
sergiu
|
Posted : Sat, 25 October 2008 21:26:30
Subject :
Fedora/RH best practices for logging from init scripts...
I'm not a programmer, but I assume that it would be good to push the output into a text file, like:
./myscript > textfile.txt
then write a script for syslog-ng, that when it starts, to copy the whole textfile.txt into your log files, like:
cat /yourtextfilelocation/textfile.txt >> /var/log/syslog.
Again, I'm not a programmer, and I'm not sure my solution is the best.
|
|
V. L. Simpson
|
Posted : Sun, 26 October 2008 16:47:42
Subject :
Fedora/RH best practices for logging from init scripts...
Try the logger command.
http://www.linuxmanpages.com/man1/logger.1.php
|
|
debianadmin
|
Posted : Wed, 29 October 2008 09:17:58
Subject :
Re: Fedora/RH best practices for logging from init scripts.
The solution will probably be a combination of the above two suggestions. Since syslogd is not running, you might as well pipe the output directly to /var/log/syslog, but I wouldn't do that to be honest, since the file /var/log/syslog is created by syslogd and has a special format, which you would probably mess up. I would rather just choose a different file, like /var/log/initscripts instead. Do not forget to catch stderr as well. You can in your script add this at the very top (right after the shebang line):
[code=xml]
exec > /var/log/initscripts 2>&1
[/code]
then all the output any command in your script generates will be appended to /var/log/initscripts. If you additionally want to use syslog, you should use logger when syslogd is running:
[code=xml]
logger -f /var/log/initscripts
[/code]
This command should run after syslogd is started.
|
|
debianadmin
|
Posted : Wed, 29 October 2008 10:52:07
Subject :
Re: Fedora/RH best practices for logging from init scripts.
It seems that under Fedora you are out of luck to use a different solution: [url]https://bugzilla.redhat.com/show_bug.cgi?id=151238[/url]. Under Debian you only would have to enable bootlogd and anything that goes to /dev/console would be logged automatically.
|