Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
1  
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
add comment

1 Answer 1

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

share|improve this answer
add comment

Your Answer

 
discard

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.