5

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>
4
  • 3
    Please provide your .plist file so we can see what properties you are using.
    – NReilingh
    Oct 9, 2014 at 11:22
  • What file inside of SystemConfiguration are you monitoring changes for? Is it possible that the file isn't modified until 40 secs after the VPN is established?
    – tron_jones
    Oct 10, 2014 at 4:09
  • From what I know about this system, I watch all the file in /Library/Preferences/SystemConfiguration. I don't know exactly which file is changing. That was the way I found here on stackexchange
    – reav0r
    Oct 10, 2014 at 9:22
  • This isn't a strong area for me but if there's a problem in your plist configuration file, an easier way of creating it would be to use LaunchControl [soma-zone.com/LaunchControl/] - see also launchd.info.
    – Harv
    Oct 22, 2014 at 17:12

1 Answer 1

1

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .