Thursday, June 9, 2011

Logging Bootup/Startup Scripts

I was writing some startup scripts in /etc/init.d/ to be run during bootup. However, there was a problem and the scripts weren't running properly. Unfortunately, there were no logs anywhere.

System Wide Logging

I found a solution in Ubuntu which was to open up /etc/default/bootlogd and set the option to yes. You supposedly see the boot logs in /var/log/boot. However, I found it was writing to /var/log/boot.log. Sort of. I got partial output (about 6 lines). The file was never fully written to.

Script Specific Logging

I found a workaround. Instead of using a system wide log, use a script specific log. Add this to your script. It will log all output.
exec > /tmp/debug-my-script.txt 2>&1

References

No comments:

Post a Comment