Benches Uncategorized

3

shell script to logout?

apple Verified

Imported from the Apple Support Forums via the Wayback Machine 🔗

Hello, I am working on an automator app that will quit all apps (which works very well), pause for several seconds and then logout a user. Right now, I am having to use the "watch me" to log out, but, it is not totally consistent in the action. Is there a shell script command?
Thanks

3 replies

Sign in or join Beachball Help to reply.

  1. 0

    Apple Support Community member

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    I don't know about a shell script, but the Applescript is:

    Tell application "System Events"
    log out
    end tell

  2. 0

    Apple Support Community member

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Oh, thank you!!!!!!

  3. 0

    Apple Support Community member

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    So, call me a picky, 'my system has to be just so' kinda guy... But I've got 5 users on my iMac. The wife and three kids. The kids have time limits on their accounts....
    Here's the thing with the time limits parental controls. It doesn't actually log out the user. (I guess that's to prevent lost documents etc.)
    Sounds nice, right? Well... check this out. My kids have parental controls on cause they REALLY like to play world of warcraft. For HOURS. So... WOW has this nice feature that doesn't let you exit the program nicely when you're in 'combat'. So, if you're in combat, and you run out of time with parental controls, the computer doesn't put the user back to the login screen. My kids have figured this out and will play for 15 hours at a stretch if we let them. (I think they should be allowed to play for a little extra time for figuring out how to beat the parental controls, but the wife disagrees)

    I remember way back when with 10.5.0 WOW and Parental controls didn't get along. -There's gotta be a relationship to this behavior.

    Anyways... Back to the problem. I'm at the login screen and no password for the kids account. Assume I can't log them in to log them out. (there's 4 users anyway - it would take too long)

    Okay then... Assume I'm logged into my user account (an admin account on the computer) and I see that there's 5 users logged in. Myself, my wife, and my 3 kids by typing users or w in the terminal. The parental controls have left my users logged in. So I pull off a killall -u username command in the terminal. I've found that this doesn't actually log out users, it just kills all their processes.

    When I type users or w in the terminal it shows me that there's indeed still 5 users logged in. The activity monitor as well tells me that there's no processes active that belong to anyone but me, and root. Yet the shell tells me that there are still users active.

    I KNOW there's a unix command that will log out a user, but no one will share this secret! It's not anywhere on the web. I've been looking for weeks!
    The reason I know, is that there's a command in Apple remote desktop to force users to log out.... Not only that, but it does it in a way that doesn't kill the loginwindow or the WindowServer processes.

    Someone PLEASE type the wee command that it takes to do this seemingly 'easy as two clicks' task.

    -Graham