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

Tuesday, June 7, 2011

Automatic Server Bootup on Power Failure

Imagine a power failure where your servers are running. Of course, they should be plugged into a UPS, but what if that goes down too? Your server will power off.

When the power comes back, your server will remain quiet unless you tell your servers to come back to life by themselves.

There are 2 things you must do in the BIOS to make this happen.

  1. Tell the server to bootup after a power failure. This is the AC Power Loss Restart option in the BIOS. This should be set to On.
  2. Ignore a missing keyboard. There is an area in the BIOS that handles halting on errors. It should be set so that it ignores keyboard errors. If this is not ignored, the server will wait for the user to press F1.