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

0
7
Asked By MellowCedar42 On

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?

4 Answers

Answered By BrightHarbor7 On

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.

Answered By QuartzMango19 On

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.

Answered By NimblePine56 On

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`.

Answered By SilverOtter88 On

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.

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.