Schedule Automatic Shutdown in Ubuntu with Cron
Scheduling an automatic shutdown in Ubuntu 22.04 LTS turns off your computer on a set schedule using a built-in time-based job scheduler called Cron (a background tool that runs commands at set times). This setup stops your PC from running all night so you save power without needing to turn it off by hand.
You can create a simple rule that shuts down your system every day at 11 PM using a few quick terminal commands. The scheduler runs silently in the background once you save the rule.
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
Setting up an automatic shutdown in Ubuntu is easy when you combine the Cron task scheduler with a basic power command. This process lets your system turn off at a specific time every day without you needing to be there. You just need to open your terminal, edit your scheduled tasks, and add the shutdown command with the exact time you want your computer to turn off.
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.
Was this guide helpful?
About the Author
Richard
Tech Writer, IT Professional
Richard is a writer at Geek Rewind who turns complex IT tasks into clear, step-by-step guides. He draws on years of hands-on experience in system administration and enterprise IT operations, focusing on Windows, Linux and WordPress: the problems people actually run into, and the fixes that work. His server and WordPress guides come from systems he runs himself. Richard builds and maintains the platform behind Geek Rewind, from its Ubuntu servers and Nginx configuration to its custom WordPress plugins. Many new tutorials start with readers' questions, and he's always glad to answer them in the comments.
No comments yet — be the first to share your thoughts!