How can I force my Linux computer to shut down at night?

0
4
Asked By MellowCedar42 On

I'm using Linux Mint and have trouble stopping computer use at a reasonable hour. Reminders and alarms are too easy for me to ignore, so I'm looking for a more enforceable solution—ideally something that shuts the computer down at a chosen time, such as 11 PM, and possibly prevents it from staying on during overnight hours. What software, scripts, cron jobs, or other methods would work?

5 Answers

Answered By QuartzPanda18 On

You can make the shutdown conditional so the computer is turned off throughout a blocked period. For example, a script can check whether the current hour is between 11 PM and 6 AM and run `/sbin/poweroff` during that window. A root cron job running every couple of minutes could enforce it even if the computer is restarted during the restricted hours. Be careful with permissions and test the script before relying on it.

Answered By CopperMeadow5 On

For a simple one-time limit, a small Bash script is enough: `sleep 3600` followed by `poweroff` will shut the computer down after an hour. You could add a warning beforehand, such as a desktop notification five minutes before shutdown, and then give yourself time to save anything important.

Answered By IndigoLattice26 On

The technical solution can help, but it’s also useful to add a physical barrier. Put a separate alarm or timer somewhere that requires you to get up and leave the computer to turn it off. Combining that with an automatic shutdown gives you both an external reminder and a consequence that’s harder to ignore.

Answered By SunnyRook31 On

Workrave may be worth trying if you want something less drastic. It can remind you to take breaks and enforce a daily usage limit. Unlike a normal alarm, it can make the limit harder to casually dismiss, though a determined user can still disable almost any software restriction.

Answered By VelvetHarbor7 On

A cron job can shut the machine down at the same time every night. Run `crontab -e` and add a line such as `45 22 * * * /sbin/shutdown -h now` to shut down daily at 10:45 PM. Make sure you save your work first, since this won’t give applications much opportunity to recover unsaved data.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.