Timed User Sessions

Timed User Sessions

Posted on 2013-01-26 by Ed Braaten

I did the following things to setup auto-logout/timed user-sessions for my son on our home computer running Linux (Ubuntu 11.04):

  1. Edited the file “/etc/security/time.conf” and added the following line:

    This limits the user “toby” to login only on weekdays between the specified times.

  2. Add the following line after the “auth” statements in the “/etc/pam.d/login” and “/etc/pam.d/gdm” files:
    account required pam_time.so
  3. Add the following lines to root’s crontab file (run “crontab -e” as the root user):
    0 15 * * 1-5 /usr/bin/zenity –warning –text=’Logging Toby off in 5 minutes!’ –display=:0.0
    5 15 * * 1-5 /usr/bin/killall -s KILL -u toby
    0 20 * * 1-5 /usr/bin/zenity –warning –text=’Logging Toby off in 5 minutes!’ –display=:0.0
    5 20 * * 1-5 /usr/bin/killall -s KILL -u toby

    The zenity command is used to display a warning dialog in the Gnome session for the user “toby” five minutes before the killall command abruptly kills all running programs and the gnome session.

  4. Add the following line to /etc/bash.bashrc:
    xhost + >& /dev/null
    This will allow the zenity command write to the user’s session (see crontab entries).

Copyright (C) 2013 by Ed Braaten.  All rights reserved.
Other Blog Entries