Skip to content
Follow
Ubuntu Linux

Schedule Automatic Shutdown in Ubuntu with Cron

Richard
Written by
Richard
Aug 29, 2022 Updated Sep 15, 2026 2 min read
How to Use Sticky Notes in Windows 11
How to Use Sticky Notes in Windows 11

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.

Advertisement

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.

⚡ Quick Answer

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.

Advertisement

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.

Advertisement

Run the commands below to edit the crontab.

🐧Bash / Shell
sudo crontab -e
⚠️WarningWhen you run crontab -e for the first time, you may get a prompt screen to choose an editor.
💻Code
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.

💻Code
30 18 * * * shutdown now
Editing crontab to schedule automatic shutdown in Ubuntu
crontab edit new line

Press CTRL + X to exit, then press Enter to save your changes, and you're done.

Advertisement

If you want to restart Ubuntu Linux instead, you'll use -r.

💻Code
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?

Tags: #Windows 11
Was this helpful?
Richard

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.

Advertisement

📚 Related Tutorials

How to Properly Shut Down Ubuntu Linux: A Complete Guide
Ubuntu Linux How to Properly Shut Down Ubuntu Linux: A Complete Guide
How to Manage Alert Sounds in Ubuntu Linux
Ubuntu Linux How to Manage Alert Sounds in Ubuntu Linux
How to Change Time Format in Ubuntu: 12h or 24h
Ubuntu Linux How to Change Time Format in Ubuntu: 12h or 24h
How to Turn "Week Numbers" on or off for Calendar in Ubuntu Linux
Ubuntu Linux How to Turn "Week Numbers" on or off for Calendar in Ubuntu Linux

No comments yet — be the first to share your thoughts!

Leave a Comment

Your email address will not be published. Required fields are marked *