I would like to run something like "sleep 3600; logout", but the logout bash command only closes the current terminal. How do I close the full Mac OS X session?
The following Applescript will logout the current user:
You can wrap this up in a bash alias using the
It is the same as clicking " > Log out [username]...", and will logout after a 2 minute wait
This is easily combined with the
..or could be combined into a single alias:
There is no "nice" way to log the current user out from Terminal in OS X. The 'messy' way of doing it is to kill that user's
Doing this is a two-step process.
Use sudo kill -9 to force kill the process which I had to do to get this to work.
So for example, when if the output to the first command is:
Then I would run
This can be combined into an bash alias:
I know this is an old question but it helped me, the command I needed on OS X 10.8 is:
I think I have found the answer to how to Gracefully Logout of Mac OS X without the 2 minute wait.
I figured out that holding Shift, Option, and Command and pressing "q" will log out gracefully and not ask "if you want to log out".
So I coded an AppleScript through Automator to:
I would argue that the "nicest" way post OS X 10.9 might be
The post OS X 10.9 documentation for launchctl is found by running
This can be tested by running