Linux.com

Author Message
Joined: Oct 17, 2008
Posts: 5
Other Topics
Posted Oct 17, 2008 at 10:12:34 PM
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...
Back to top Profile Email Website
sergiu
Joined Oct 25, 2008
Posts: 1

Other Topics
Posted: Oct 25, 2008 9:26:30 PM
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.
Back to top Profile Email Website
V. L. Simpson
Joined Jan 01, 1970
Posts: 1

Other Topics
Posted: Oct 26, 2008 4:47:42 PM
Subject: Fedora/RH best practices for logging from init scripts...
Try the logger command. http://www.linuxmanpages.com/man1/logger.1.php
Back to top Profile Email Website
debianadmin
Joined Oct 29, 2008
Posts: 2

Other Topics
Posted: Oct 29, 2008 9:17:58 AM
Subject: 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.
Back to top Profile Email Website
debianadmin
Joined Oct 29, 2008
Posts: 2

Other Topics
Posted: Oct 29, 2008 10:52:07 AM
Subject: 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.
Back to top Profile Email Website
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya