How can I force Linux to shut down or block access at bedtime?

September 17, 2026 4 answers
Asked by MellowCedar42
I'm using Linux Mint and have trouble stopping computer use at night, which often leads to going to sleep around 3:00 AM. Alarms and reminders haven't helped because I simply ignore them. I'm looking for a stronger solution, such as automatically shutting the computer down at a set time and preventing it from staying available during certain hours. Are there any applications, scripts, or system tools that can help enforce a schedule?

Answers

SilverOtter88
If you want to prevent simply turning the computer back on and continuing, use a script that checks the current time and powers off whenever it runs during restricted hours. A cron job checking every couple of minutes can enforce a window such as 11 PM through 6 AM. Keep in mind that anyone with administrator access can disable or edit the script, so combining it with practical habitsโ€”like placing alarms away from the deskโ€”may make it more effective.
Reply to this answer
NimblePine56
For a simple countdown, create a script like this and run it when you want the timer to begin: `#!/bin/bash` followed by `sleep 3600` and then `poweroff`. That waits one hour and shuts down the computer. You could also use a systemd timer or cron job to run it at a particular clock time.

CopperVale31: You can add a warning before shutdown by inserting a notification command between two waitsโ€”for example, wait an hour, display โ€œTurning off in five minutes,โ€ wait another 300 seconds, and then run `poweroff`.

Reply to this answer
QuartzMango19
A scheduled shutdown can be set up with cron. Open the root crontab with `sudo crontab -e`, then add a line such as `45 22 * * * /sbin/shutdown -h now` to shut the machine down every day at 10:45 PM. Be aware that unsaved work will be lost.
Reply to this answer
BrightHarbor7
Workrave may be worth trying. It can remind you to take breaks and also enforce a daily usage limit. Itโ€™s free, so itโ€™s an easy option to test.
Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions