5

As part of a kiosk system, I have set up a Guest account on a Mac OS X Snow Leopard computer. This account is cleared every time someone logs off the computer. However, plenty of people don't. Is there any way that I can automatically log out this guest account after a period of inactivity?

I tried using the security preferences pane, but that just causes the confirm logout dialog to show up.

I have hacked around the /System/Library/User Templates/ folder, so I can set the screensaver, desktop background, &c. If something like ScriptSaver can solve my problem, I will gladly use it.

4
  • Would there really be harm in just setting a daily shut down and power up at the end/beginning of the day?
    – bmike
    Commented Jul 20, 2011 at 3:16
  • 1
    @bmike I do want it to be after a period of inactivity, not on a scheduled basis. Users can't be trusted to log out when they're done...
    – user3231
    Commented Jul 20, 2011 at 3:26
  • Fair enough - I'll see if I can gin up a launchd login item to set the automatic timeout. It sure seems like it should be possible, i just will have to re-examine how the creation of the guest folder happens each log in.
    – bmike
    Commented Jul 20, 2011 at 3:29
  • @bmike I just want a simple script, or a few lines of code, that can force logout of a guest account. Timing is not an issue. There is scriptsaver, sleepwatcher, et al. for that. If you could whip up something, or point me in the right direction, it would be extremely helpful.
    – user3231
    Commented Jul 20, 2011 at 3:33

3 Answers 3

3

Maybe you could consider using SleepWatcher instead of the Security.prefPane; it´s a unix utility you could use to force a logout (or anything else via AppleScript) after a certain period of inactivity.

7
  • I could use ScriptSaver, too. The problem is I don't have a command to force the Guest account to logout. If you have one, it would be helpful...
    – user3231
    Commented Jul 18, 2011 at 14:56
  • 1
    It is almost a catch 22 - sudo killall loginwindow will force a log out no matter what, but you need to lock out terminal so that smart users will not try to sudo - I suppose adding killall loginwindow to the sudo whitelist isn't any worse than letting the user log out. You might also get Faronics deep freeze to ensure everything is perfectly frozen each reboot.
    – bmike
    Commented Jul 20, 2011 at 3:40
  • @Soumya92: You should maybe use AppleScript´s ` tell application "loginwindow" to «event aevtrlgo» ` instead, so it only logs out the guest user, not every user.
    – Asmus
    Commented Jul 20, 2011 at 10:13
  • I don't see how this is the correct solution to this problem. SleepWatcher is a third party tool and at this point is quite old. The webpage references 10.5. Seems like some script show allow the user (and me) to blow past that confirmation dialog and also delete the Guest folder in the Users dir.
    – zeeple
    Commented Jan 29, 2019 at 19:44
  • @zeeple (1) As this question and my answer are nearly 8 years old, there may be better solutions around by now, feel free to post them as a separate answer! (2) the tool may be old, but the webpage says "running with Mac OS X 10.5 and higher" and it appears to run fine on 10.14.2 (e.g. ./sleepwatcher -t 20 -i ls ) (3) I don't quite understand the final sentence of your comment; please elaborate!
    – Asmus
    Commented Jan 29, 2019 at 20:26
3

You can use a commercial product called Power Manager to log out a user after a period of inactivity.

Power Manager will warn the user before starting the log out. During log out any open applications will be quit; applications attempting to block log out will be force quit after a short delay.

Power Manager for Mac OS X

Disclosure: I work for the company who make Power Manager.

3
  • I could also write an app to do just that instead of the bevy of features that Power Manager provides. No doubt it is a powerful tool, but I can't justify purchasing it solely for this purpose. It is just a kiosk computer. I can't find a good command or code sample to log out the guest account
    – user3231
    Commented Jul 20, 2011 at 2:43
  • Great answer and disclosure. How is this different than the built in controls? Does it run at boot rather than at the user level?
    – bmike
    Commented Jul 20, 2011 at 3:42
  • Power Manager has a number of advantages. Power Manager will show a warning, it will ensure log out takes place even where an application would traditionally block log out. The event can be conditional based on running applications or the result of an external script. See the documentation for specifics: dssw.co.uk/powermanager/guide/v4 Commented Jul 20, 2011 at 4:12
0

Haven't tried this with a aGuest account, but no reason it shouldn't work there.

In

System Preferences > Security > General

is a checkbox labeled "Log out after XX minutes of inactivity"

Here set your desired minute amount and let it do the magic!

2
  • 1
    I did. As I mentioned, that just shows me the Confirm Logout box. The reason it won't work on a Guest account is because logging out of a guest account deletes the session data, so a confirmation is required.
    – user3231
    Commented Jul 18, 2011 at 6:03
  • Additionally, that setting applies to ALL users, not just the guest account.
    – Gorb
    Commented Mar 13, 2013 at 20:48

You must log in to answer this question.