Retriev3r
8/24/2017 - 6:34 PM

How to run a script before shutting down MacOS

How to run a script before shutting down MacOS

1. The file can contain something like :
#!/bin/bash
say 'Hasta la vista baby!'

2. Then give exuction rights :
sudo chmod +x /Users/Shared/logoutHook.sh

3. Finally hook the script to the logout procedure :
sudo defaults write com.apple.loginwindow LogoutHook /Users/Shared/logoutHook.sh