4

With 10.6 I used to kill the process loginwindow to logout another user, but with 10.8 I noticed that even if I do so, many processes from that user stay active.

So, is there a way to logout another user in 10.8, other than logging him in or manually killing all his processes?

6
  • OS X now runs process as users even when they haven't logged in for the first time. What problem exactly are you seeking to solve? You can still kill all processes for a specific user and then know the remaining processes were started by the system.
    – bmike
    Nov 7, 2013 at 18:54
  • @bmike not exactly: if an user never logged in since power up, I see no process belonging to him. The problem I'm trying to solve is, as I said, to logout an user without having to switch to his account to do that.
    – o0'.
    Nov 7, 2013 at 19:07
  • Hmm - all my systems start launchd, distnoted and cfprefsd processes for each local user when the machine starts whether anyone is logged in or not.
    – bmike
    Nov 7, 2013 at 19:17
  • @bmike I believe you, not sure why it doesn't happen here
    – o0'.
    Nov 7, 2013 at 19:25
  • Just wait till you get to Mavericks when user processes stick around running even after you log that user out from the GUI. I don't doubt what you're seeing either :-)
    – bmike
    Nov 7, 2013 at 19:30

2 Answers 2

5

As an administrator:

sudo su - user_to_be_logged_out
kill -9 -1

That will log out any user by ending all of the user processes. Use care to not issue the kill -9 -1 as root else some work would be expected to be lost as the system would immediately self-destroy all processes.

There are of course one line commands, but I like having a pause to look and make sure I switched to the correct user before issuing a powerful command like kill -9 -1 and I also avoid at all costs having sudo appear before that kill since I don't even want to kill all processes as root.

2

Like bmike mentioned but combining the commands into an alias that can be used in /bin/tcsh shell. Again this is nice and fast but be careful. Don’t do this on root or yourself.

alias ku "sudo su user_to_be_logged_out -c 'kill -9 -1'"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .