Is "auto logout" possible?

Questions about applications and software
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Chrisbo

Is "auto logout" possible?

Post by Chrisbo »

I've got a single computer with multiple users that I can't seem to (reliably) teach them to logout after they're done with the computer. When the next user comes to the computer, they just select "Switch User" and then I'm left with up to 3 people being logged in on top of one another.

Is there a way I can have the system log them out after so many minutes of inactivity?

Thank you for your help.

Chrisbo
Husse

Re: Is "auto logout" possible?

Post by Husse »

I know how to log out automatically from the command line, but from a GUI was harder - to be honest I don't know :shock:
DrHu

Re: Is "auto logout" possible?

Post by DrHu »

Unfortunately most of the functionality to enable this action will be at the command line level..
--I can't think of any GUI application that does it
http://blogs.techrepublic.com.com/security/?p=285
--but in windows or Linux, the process is similar enough..
Power management can lock the user, but other options require more manipulation

You will have to do some editing, but you could control their (users) login times
http://www.debian-administration.org/articles/227
http://skindley.wordpress.com/2006/12/1 ... s-by-time/

So the message might be:
  • If you don't logout when finished, you will be logged out by the system
  • These are your login times to use the computer
  • If you are able to manage logging off when finished, the system logout will no longer apply to you
Another way of doing it indirectly is to kill /force logoff of a user at a specific time via cron (time scheduler)
http://ubuntuguide.net/make-programappl ... duled-time

Ubuntu 9.04 (Mint 7) possibilities..
http://ubuntuforums.org/showthread.php?t=355630
http://bloggerdigest.blogspot.com/2006/ ... e-few.html
http://www.cyberciti.biz/tips/howto-lin ... users.html
Chrisbo

Re: Is "auto logout" possible?

Post by Chrisbo »

DrHu,

Thank you very much for the information. I'll start on it as soon as I get back to work, and let you know how it goes!

Chrisbo
Chrisbo

Re: Is "auto logout" possible?

Post by Chrisbo »

I guess I had a bit more time this morning to look into DrHu's suggestions. It appears that for most of these links, it involves restricting login times then logging out the users. I have no need (yet) to restrict time on the computer, and am just looking for an auto logout after idle. I have found many requests for this type of functionality and it may be worth adding to the distribution at some point.

I found a package called "autolog" but I'm not sure that fits my needs.

I'm trying to wrap my head around "why-you're-editing-what-you're-editing" and I think I'll be able to make it fit my needs, however, I'm still pursuing the issue and will come back here and post what I find.

Chrisbo
DrHu

Re: Is "auto logout" possible?

Post by DrHu »

Chrisbo wrote:I found a package called "autolog" but I'm not sure that fits my needs.
OK, it was in this link
http://ubuntuforums.org/showthread.php?t=355630

http://unixsystems.blogspot.com/2007/10 ... ut-on.html
  • To make modifications apply to all users on the system, specify the TMOUT variable in /etc/ profile.
  • Howto
And mentioned other shells (csh, tsh, the most well known one is Korne shell, but not as popular in Linux), also suggesting if you searched for autolog (Google) you would find it, so..
http://pank.org/blog/archives/000871.html
  • For shells that read /etc/profile (like bash, ksh, sh) append:
    TMOUT=N
    export TMOUT
    (In Debian you can get away by putting TMOUT=N in /etc/environment).

    If you use csh, tcsh, or any in the *csh family, then
    edit /etc/csh.cshrc and add:
    set autologout = 15
And how someone might prevent that autlogout (timeout)
http://hacktux.com/disable/auto/logout
  • Find that your shell is logging you out after a certain period of inactivity? You can tweak the number of seconds before the logout, or disable auto logout completely.
Chrisbo

Re: Is "auto logout" possible?

Post by Chrisbo »

Sorry I'm finally getting around to this, but I've been away for a while from this system. Anyway, after searching through my computer, I've found the "profile" file in /etc and this is what it has in it:
--------------------
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).

if [ -d /etc/profile.d ]; then
for i in /etc/profile.d/*.sh; do
if [ -r $i ]; then
. $i
fi
done
unset i
fi

if [ "$PS1" ]; then
if [ "$BASH" ]; then
PS1='\u@\h:\w\$ '
if [ -f /etc/bash.bashrc ]; then
. /etc/bash.bashrc
fi
else
if [ "`id -u`" -eq 0 ]; then
PS1='# '
else
PS1='$ '
fi
fi
fi

umask 022

---------------------

given this info, where do I put the TMOUT lines?

Thanks!

Chrisbo
Husse

Re: Is "auto logout" possible?

Post by Husse »

given this info, where do I put the TMOUT lines?
I don't think it matters as long as you don't get entangled in something
Put them at the very end
Chrisbo

Re: Is "auto logout" possible?

Post by Chrisbo »

Okay, I'll give that a try as soon as I try this. I guess I missed this line from DrHu's post on 22 NOV:
(In Debian you can get away by putting TMOUT=N in /etc/environment)
So, I'll edit that file (which has only one line of code - a PATH statement - and see what happens.

Thanks again and I'll post back with the results.

Cheers,
Chrisbo
Chrisbo

Re: Is "auto logout" possible?

Post by Chrisbo »

I tried placing the "TMOUT=300" (which is only a test value) in both the /etc/profile and /etc/environment files - only one at a time - but neither of these worked.

I'm pretty much at a loss after this.

Does anyone else have a suggestion?

Chrisbo
DrHu

Re: Is "auto logout" possible?

Post by DrHu »

http://hacktux.com/disable/auto/logout
http://www.youtube.com/watch?v=sAFEbImxUfw
It logs out the shell, so if you had a terminal open and export tmout=10, that terminal would close after 10secs.

Is autologout possible ?..
http://www.cyberciti.biz/tips/increase- ... nsole.html
https://blueprints.launchpad.net/ubuntu ... autologout
http://www.linuxforums.org/forum/redhat ... gnome.html
  • Some suggest setting a screen-saver timer, start screen-saver after a certain time, also set a password for it for that user (different from the user), so that they do not know the screen-saver password, of course they might be able to override that, if they start practicing with the terminal or discover the password
That method a screen-saver activated with a different password for those users might be a relatively simple method of getting and automatic screen-lock, disabling access to the system
  • They could reboot and login again
    They might be able to crash the desktop (ctrl-alt-backspace)
Chrisbo

Re: Is "auto logout" possible?

Post by Chrisbo »

Okay, no luck with those ideas, but let's attack this from another angle. I've been watching how people actually switch users and I see that they use the "Switch User" button on the LOGOUT dialog box instead of clicking on the logout button.

Is there a way to remove the "Switch User" button? That way, they'll have no choice but to logout the previous user? My users aren't computer-savvy enough to figure out how to bypass this (though that may come back to haunt me) and it should solve my problem.

Whaddya think?

Chrisbo
Husse

Re: Is "auto logout" possible?

Post by Husse »

If you have Helena right click the menu button > Preferences > System tab and you can disable the log out option, but that's the opposite to what you want, or?
Easy to restore but you say they are not computer savvy :)
Smiff2

Re: Is "auto logout" possible?

Post by Smiff2 »

sorry to dig up an old thread but this isn't solved afaik.

gnome-session-save --logout
or
gnome-session-save --force-logout

are the commands you want.. (for mint with gnome obviously)
i'm trying to work out how to run them automatically after x seconds of idle.. using crontab -e doesn't seem to work (works on its own, but not from cron?). must be possible!
User avatar
Pilosopong Tasyo
Level 6
Level 6
Posts: 1432
Joined: Mon Jun 22, 2009 3:26 am
Location: Philippines

Re: Is "auto logout" possible?

Post by Pilosopong Tasyo »

Smiff2 wrote:using crontab -e doesn't seem to work (works on its own, but not from cron?).
How is the command being triggered? As part of a script? As an entry to the cron table itself? Try one of these:

Code: Select all

/usr/bin/gnome-session-save...

Code: Select all

DISPLAY=:0 gnome-session-save...

Code: Select all

DISPLAY=:0 /usr/bin/gnome-session-save...
o Give a man a fish and he will eat for a day. Teach him how to fish and he will eat for a lifetime!
o If an issue has been fixed, please edit your first post and add the word [SOLVED].
Smiff2

Re: Is "auto logout" possible?

Post by Smiff2 »

i tried both (calling a script from crontab, putting command in crontab)
neither work

adding DISPLAY:=0 stopped script working, probably because its the wrong display number (error opening display..)

seems like cron just isn't working, any ideas how to debug that
update: checked logs, cron is working, this is the "grandchild failed EXIT status 1" error and i can't find a solution right now :/

btw, --logout-display is perfect as i think it waits 60s then logs out if user doesn't cancel.. i.e. could be run from cron once a night for each user and would do what i want :)

or better, how to call a script on user idle, like TMOUT, but that works for gui sessions ?


thanks!
User avatar
Pilosopong Tasyo
Level 6
Level 6
Posts: 1432
Joined: Mon Jun 22, 2009 3:26 am
Location: Philippines

Re: Is "auto logout" possible?

Post by Pilosopong Tasyo »

Smiff2 wrote:...or better, how to call a script on user idle...
Well, a few ideas come to mind. Assuming it has been configured for a given user, you can use:

Code: Select all

gnome-screensaver-command -q

Code: Select all

gnome-screensaver-command -t
in your script to find out if the screensaver's running and for how long it has been running, respectively. Filter the relevant information, and use:

Code: Select all

pkill -SIGKILL -u <username>
to forcibly log out the user (albeit it's an ungraceful exit, akin to pressing Ctrl+Alt+Backspace to restart X).

You'll still need to set cron to trigger the script on a regular basis, in this case, every minute.
o Give a man a fish and he will eat for a day. Teach him how to fish and he will eat for a lifetime!
o If an issue has been fixed, please edit your first post and add the word [SOLVED].
Smiff2

Re: Is "auto logout" possible?

Post by Smiff2 »

just using the gnome-session-save logout would be simplest, if i can get cron to run it.. e..g once a night per user.
i know about pkill, used that when setting up accounts, but don't want to run it routinely, might cause user home corruption.
might be an ubuntu 10.10/mint10 issue? will try on mint11 tomorrow.
Smiff2

Re: Is "auto logout" possible?

Post by Smiff2 »

nah same error in mint11

Code: Select all

Aug 20 21:14:01 CENTRE CRON[24908]: (username) CMD (/usr/bin/gnome-session-save --logout-display)
Aug 20 21:14:01 CENTRE CRON[24907]: (CRON) error (grandchild #24908 failed with exit status 1)
Aug 20 21:14:01 CENTRE CRON[24907]: (CRON) info (No MTA installed, discarding output)
any ideas please?

saw this on ubuntu forum
"If it runs manually just fine, but fails from cron, then it's either a malformed crontab line or a missing environment variable in the script."

update:

Code: Select all

export DISPLAY:=0 && /usr/bin/gnome-session-save --logout-display
seems to work in mint11, but not 10!
damn.. or could be that its a different system with different users logged on? how to get current DISPLAY?
Smiff2

Re: Is "auto logout" possible?

Post by Smiff2 »

right, i just discovered the "gnome-schedule" package.

use this, set it to X Application, command is gnome-session-save with options as explained above, seems to work fine!
yay.

problems
1) users can disable their own scheduled tasks, but this shouldn't be a big problem with non-technical users for now. i could just hide the menu entry for gnome-schedule if they don't need to schedule their own tasks..
2) crontabs are stored per machine (and per user), so if you have an nfs network you seem to need to configure this for every user for every machine. tedious. i can't seem to get templates to work across users either.

***

the other tip i will add, for OP, is that it seems to help to edit all your major app launchers
e.g. which firefox
sudo nano /usr/bin/firefox
"nice -nX" the exec line, where X is a small positive integer.
this helps keep system responsive with multiple users.. i think.
Locked

Return to “Software & Applications”