Sometimes you may need to automatically shutdown your Linux system at a specific time, or after a specific time interval. You can easily do this in almost every Linux system. In this article, we will look at how to schedule shutdown in Ubuntu Linux.
How to Schedule Shutdown in Ubuntu Linux
Here are the steps to schedule shutdown in Ubuntu Linux using shutdown command.
Here is the command to shutdown your Linux system after 30 minutes
$ sudo shutdown -P +30
In the above command you need to specify the number of minutes prefixed by + sign, after -P option.
Here is the command to shutdown at 2PM.
$ sudo shutdown -P 14:00
In the above command you need to mention the exact time to shutdown in HH:MM format, after -P option
If you want to shutdown now, here is the command for it. You need to mention now keyword after -P option.
$ sudo shutdown -P now
shutdown command is smart enough to understand when to shut down depending on the value you input after -P option. You want to specify a time interval you need to prefix it with + sign. If you want to specify a time, mention it in HH:MM format. If you want to shutdown now, just mention the keyword now or +0 after -P option.
If you want to cancel a scheduled shutdown, just use -c option after shutdown command.
sudo shutdown -c
You may also use this command in any of your shell script or cronjobs. Also, shutdown command is available in almost every Linux system.