Since I over-use my computer, I would like to block it for few hours, for example every day from 23 to 7, so that I cannot use it in that time frame.Currently, I am using crontab to suspend/shutdown the computer when it comes the time, and I do that every minute, so that - in general - if I try to log-in or turn on the computer, I have only few seconds before it is suspended again. The issue is that those few seconds are enough to change crontab and lock the mechanism.So, I thought about blocking the login process completely (even for root!) in those hours, so that nobody could access the computer in any way, from 23 to 7. If I wanted to disable this behavior, I had to do it beforehand.So, how can I configure my Linux box so that, for few hours, nobody can login? Should I use PAM? If yes, how?Note: I would like to prevent logging in both with GDM and shell.
How do I lock my Linux box for few hours?
cron;login;pam
Another approach is to disable the mouse and keyboard (assuming a system with USB input devices):00 23 * * * rmmod usbhid00  7 * * * modprobe usbhidThis won't prevent you from turning the system off and on again, which would re-enable the keyboard and mouse... You could play with blacklisting the module if you want to prevent that, but you'd probably need to rebuild your initramfs every time (usbhid needs to be loaded very early during the boot, since you want a working keyboard to fix things when the system can't boot).If usbhid is built into the kernel on your system (e.g. Fedora), you can still achieve the same effect by unbinding all HID devices; the hard part then is re-binding them at 7am  you'll need to store somewhere the drivers from which they were unbound (unless there's a way of re-enumerating them). To unbind all devices:for device in /sys/bus/hid/devices/*; do    echo ${device##*/} > ${device}/driver/unbinddone(with appropriate error checking of course). To re-bind, you need to remember what driver the ${device}/driver pointed at, and echo the device identifier to bind in the driver's directory.