View Full Version : Logout script in 10.4.7 does not work?

11-23-2006, 03:28 PM
I tried to set a logout script to turn my system volume down as follows:

sudo defaults write /Library/Preferences/com.apple.loginwindow LogoutHook "/logoutscript.command"

/logoutscript.command contains the following


/usr/bin/osascript -e 'set volume 0'

The script runs by itself when manually invoked, but does not run when I log out. The permissions on the script are "-rwxrwxrwx" and I even tried setting owner/group to root and wheel since I understand the script runs as root.

I checked the com.apple.loginwindow.plist file with the property list editor and find the defaults command made the entry.

How would I determine why it is not running?

Thanks in advance

11-23-2006, 03:52 PM
1) See if Mike Bombich's page about login/logout scripts helps:

2) See if you can get it to work with something other than an AppleScript command - .e.g. try a script that just writes a timestamp to a file:

date >> /tmp/foo

11-23-2006, 04:03 PM
sudo defaults write /Library/Preferences/com.apple.loginwindow LogoutHook "/logoutscript.command"
This command writes to the "/Library/Preferences/com.apple.loginwindow.plist" file, which was the correct location for loginwindow hooks in 10.3, but is no longer valid in 10.4 - it was changed for security reasons.

In 10.4, the file is "/private/var/root/Library/Preferences/com.apple.loginwindow.plist" so to write to it, you could use eg:sudo defaults write com.apple.loginwindow LogoutHook "/logoutscript.command"Note that your current permissions on the script allow any user to edit it to run their own commands as "root" (loginwindow hooks run as "root"). It would be preferable to change the permissions on the script, and its location to somewhere that only "root" can modify.