Automatically Restart launchd Scripts On Change
This is the launchd script I use to restart launchd scripts when I'm working on them.
~/Library/LaunchAgents/com.theidofalan.restart_launchd_scripts.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.theidofalan.restart_launchd_scripts</string>
<key>ProgramArguments</key>
<array>
<string>/bin/bash</string>
<string>-c</string>
<string>
touch /tmp/launchd_ping_a.txt
launchctl unload ~/Library/LaunchAgents/com.alanwsmith.* || true
launchctl load ~/Library/LaunchAgents/com.alanwsmith.*
touch /tmp/launchd_ping_b.txt
</string>
</array>
<key>WatchPaths</key>
<array>
<string>/Users/alan/Library/LaunchAgents</string>
</array>
<key>StandardErrorPath</key>
<string>/tmp/launchd_auto_restart.log</string>
<key>StandardOutPath</key>
<string>/tmp/launchd_auto_restart.log</string>
</dict>
</plist>
Notes
-
The restarts everything in my name space. So, anything they do on startup gets triggered each time. Not an issue for me, but something to keep an eye on
~ fin ~