Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Depending on the restart of the system, I need to make my application taking some follow up.

my system is get restarted as following:

  1. my self as system admin rebooting sudo init 6 or sudo reboot
  2. my self as system admin init 0 or sudo shutdown
  3. NOT myself, System crash of get frozen and hangs (physically power off and power on)
  4. NOT myself, System off, power failure (physically need to power on)

Now, when I am not involved the system is either having reboot or shutdown where I have no, idea for those cases.

But in my every power down/power off I have one preset problem where second hardware I need to send commands for setting configuration which match with my box.

So, how can I detect the previous actions? Was it frozen, was it shutdown, was it reboot or was it etc. etc. So that I can on boot read the log and take related actions?

share|improve this question
you can create a file somewhere as a flag for successful boot and delete the file through the regular shutdown/restart procedure. If during the boot you find the file not deleted - that means a failed reboot. Maybe content of the file also can be indicative. – jet Sep 19 '13 at 22:52

You might want to have a look at the last command.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.