LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Desktop (https://www.linuxquestions.org/questions/linux-desktop-74/)
-   -   How to detect unclean shutdown? (https://www.linuxquestions.org/questions/linux-desktop-74/how-to-detect-unclean-shutdown-948736/)

paldebojyoti 06-06-2012 12:28 AM

How to detect unclean shutdown?
 
Hello All,
I would like to know if is there any way to detect whether the last shutdown was graceful or not.
Regards,
Deb

414N 06-06-2012 12:48 AM

I don't know the distro you're using at the moment (maybe Ubuntu?), but for Slackware there's a straight way to detect a graceful shutdown.
If you add this line:
Code:

touch /etc/fastboot
to the /etc/rc.d/rc.local_shutdown script, every time you shutdown your computer right that file is created and, on next reboot, Slackware boot scripts search for it and, if found, fsck checks are skipped and that file is removed.
I guess you can adopt this approach on every distribution, given you tailor it to your boot process mechanics.

paldebojyoti 06-06-2012 02:01 AM

Hello,
Thanks a lot for your answer. It gives me the option for detecting the unclean shutdown.
But at the same time, I would like to know how does ubuntu system detects the unclean shutdown.
Regards,
Deb

414N 06-06-2012 02:22 AM

If you're referring to the automatically performed fsck runs after an unclean shutdown, those are caused by the mount program detecting a dirty filesystem while mounting /etc/fstab contents. They're not distro specific.


All times are GMT -5. The time now is 06:29 PM.