2

I'd like to force my account to log out at a specific time as a self-restraint measure (e.g., to ensure I go to bed on time). And for the script to run whenever I try logging in after that time between two specified times (e.g., 11pm-5am). Potentially tied to internet time so it cannot be avoided through simply changing the time. Perhaps making use of:

sudo pkill -KILL -u <username>

1 Answers1

1

The command sudo pkill -KILL -u <username> would be suitable to log another user out. To execute this commands to log you forcefully out at a specific time, you may set up a cron job that executes the command at 11 pm. cron is still installed by default on Ubuntu 18.04. Alternatively, on more recent linux systems including Ubuntu that use systemd, systemd can be used to run jobs on specific times.

Between 11pm-5am, you could block your possibility to login by locking your password. Credit goes here. Apparently it is possible to deny login access during certain times by adding an entry in /etc/security/time.conf. In your case, the line would look like: login ; * ; !<youruser> ; !Al2300-0500

vanadium
  • 97,564