Launchd starts event 40 seconds later?
I've created a .plist
file, which should act as system daemon (global with root
user). This .plist
file listens to the settings
directory for changes like changing network settings. When this happens it should start a Bash script.
However, it works but not as expected. When I open a VPN connection it takes about 40 seconds until the Bash script will be executed. I would like it to be executed right after I open the VPN connection.
How to remove the delay before the launch?
Here is the code of .plist
file:
<plist version="1.0">
<dict>
<key>Label</key>
<string>lucafuhl.vpnhelper</string>
<key>Program</key>
<string>/Users/vpnhelper.sh</string>
<key>WatchPaths</key>
<string>/Library/Preferences/SystemConfiguration</string>
</dict>
</plist>
Two things:
Try placing your
<string>/Library/Preferences/SystemConfiguration</string>
inside an
<array>
</array>
Additionally you may be able to watch to see when the change actually happens with the below command.
sudo fs_usage -f filesys | grep /Library/Preferences/SystemConfiguration