Schedule Automatic Shutdown in Ubuntu with Cron
Schedule an automatic shutdown in Ubuntu using Cron, a tool that runs commands automatically at specific times.
Cron lets you set up tasks to happen exactly when you want them to, like shutting down your computer every night to save power.
This method is common in Linux, unlike Windows where you might use different tools.
You’ll use straightforward commands to tell Cron when to turn off your Ubuntu 22.04 LTS system, for example, at 11 PM daily.
Schedule an automatic shutdown in Ubuntu by editing your crontab with `sudo crontab -e`. Add a line like `30 18 * * * shutdown now` to shut down daily at 6:30 PM. Save the file to activate the scheduled task.
How to automatically turn off Ubuntu Linux
You can set up an automatic shutdown for your Ubuntu computer using a built-in tool called Cron. This lets you schedule a specific time for your computer to turn off by itself, which is handy for saving power or ensuring it’s off when you leave it.
To do that, you’ll need to read two posts:
After reading the post above, you should know how Cron works and how to shut down Ubuntu Linux.
For example, if you want to shut down your Ubuntu Linux computer every 6:30 PM, you’ll edit crontab, add the shutdown command, and specify the date and time.
Run the commands below to edit the crontab.
sudo crontab -e
no crontab for root - using an empty one Select an editor. To change later, run 'select-editor'. 1. /bin/nano <---- easiest 2. /usr/bin/vim.tiny 3. /bin/ed Choose 1-3 [1]: 1
Then add the command on a new line below to shutdown daily at 6:30 PM.
30 18 * * * shutdown now

Press Ctrl+X to exit, then press Enter to save your changes, and you’re done.
If you want to restart Ubuntu Linux instead, you’ll use -r.
shutdown -r now
Again, using the post above about Cron, you can specify different days, dates, times, and other variables in Cron.
That should do it!
Conclusion:
- Regularly shutting down your Ubuntu Linux system using Cron can help save energy and reduce electricity costs.
- Familiarizing yourself with the command line console and understanding how Cron works is crucial for scheduling automated tasks.
- Be sure to refer to the recommended tutorials for detailed guidance on using Cron and efficiently managing shutdown and restart processes in Ubuntu Linux.
How to sudo shutdown immediately?
1) Shutting the system down immediately The command "sudo shutdown -h now" initiates an immediate system shutdown on a Linux system.
How to shutdown Ubuntu in 30 minutes?
$ sudo shutdown -r now $ sudo shutdown -r +30 "System will reboot in 30 minutes for updates."
How to instant shutdown in Ubuntu?
I want to shut down right now. So I'm going to add the word now to the end sudo shutdown. Now that's going to tell the system to go offline. Right.
Was this guide helpful?
About the Author
Richard
Tech Writer, IT Professional
Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.
No comments yet — be the first to share your thoughts!