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:

   &lt;plist version="1.0"&gt;
   &lt;dict&gt;
        &lt;key&gt;Label&lt;/key&gt;
        &lt;string&gt;lucafuhl.vpnhelper&lt;/string&gt;
            &lt;key&gt;Program&lt;/key&gt;
            &lt;string&gt;/Users/vpnhelper.sh&lt;/string&gt;
        &lt;key&gt;WatchPaths&lt;/key&gt;
            &lt;string&gt;/Library/Preferences/SystemConfiguration&lt;/string&gt;
    &lt;/dict&gt;
    &lt;/plist&gt;
Two things:

Try placing your

&lt;string&gt;/Library/Preferences/SystemConfiguration&lt;/string&gt; 


inside an 

&lt;array&gt; 
&lt;/array&gt;


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