Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting a scheduled shutdown

I have a cmd script that will execute a set of patches, and it's designed to abort if a reboot is required to avoid patching issues. I'd also like to extend the script to abort if a reboot is scheduled (E.g. via the "shutdown" command) in order to avoid reboots mid patch if possible. Unfortunately I haven't managed to find a way to detect this apart from attempting to schedule another shutdown, which results in:

A system shutdown has already been scheduled.(1190)

While I could theoretically use this I don't think it would be good practice to scare logged in users every time I needed to check for a scheduled reboot. What I really need is a way to QUERY the state modified by the "shutdown" command.

Is this possible? I'll be happy with really any solution that doesn't involve me having an application running permanently on the system to catch the shutdown events (which I don't think even get sent around until the shutdown is actually triggered)

like image 741
Ificator Avatar asked May 27 '11 18:05

Ificator


1 Answers

You can use:

Shutdown /a "for aborting the scheduled"

then use shutdown again to create another schedule.

like image 110
Tuấn Tú Nguyễn Avatar answered Sep 20 '22 18:09

Tuấn Tú Nguyễn