7

I have been trying to determine if a shutdown has been scheduled in my system (Ubuntu 17.10). If I input via terminal "shutdown 100", it confirms that system will shut down at a time. But later on, how can I check which time it was if I have that terminal close already.

I found several solutions but none of them works:

ps -ef | grep shutdown

It shows shutdown all the time, even if shutdown has been cancelled.

systemctl status systemd-shutdownd.service

It seems it does not work anymore

cat /run/systemd/shutdown/scheduled

It returns the same either if there is shutdown pending or not.

3
  • 1
    How did you schedule the shut-down or how do you presume the shut-down was scheduled? Jan 10, 2018 at 16:08
  • Through terminal. "shutdown 10". I cancel it with "shutdown -c". Jan 10, 2018 at 16:53
  • 1
    Could you please edit your post, when you want to clarify something or add information? It’s best to have everything relevant in one place. Additionally, comments may be deleted for various reasons. Thanks. Jan 10, 2018 at 17:51

2 Answers 2

12

A very simple solution:

date -d @`cat /run/systemd/shutdown/scheduled | head -n 1 | cut -c6-15`
1
  • Just retested on focal (20.04) server. Works perfectly fine. (Fabian Jakobs solution is not for server installations 'cause it requires a Desktop / GUI installed.) The use case for the question occurs to be server rather than desktop. Thank you. Unfortunately not marked as correct (yet).
    – mats1995
    Jan 9, 2022 at 23:28
6

I've had success using

$ busctl get-property org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager ScheduledShutdown

For example:

$ sudo shutdown -h +30                                                                                                                                                                                                                                                                                                           
Shutdown scheduled for Wed 2018-10-10 09:33:44 UTC, use 'shutdown -c' to cancel.
$ busctl get-property org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager ScheduledShutdown
(st) "poweroff" 1539164024057786
$ sudo shutdown -c
$ busctl get-property org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager ScheduledShutdown
(st) "" 0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .