Posted on 10-31-2019 04:30 PM
We've been using the following trigger in a LaunchDaemon to spawn a script that disables Wifi:
<key>WatchPaths</key>
<array>
<string>/Library/Preferences/SystemConfiguration</string>
</array>
<key>RunAtLoad</key>
This has been working fine, but I've recently noticed in '/var/log/system.log' that the LaunchDaemon is being spawned multiple times in bursts every ~30 seconds:
Oct 31 16:19:56 --- last message repeated 2 times ---
Oct 31 16:19:56 MALKiosk-22462 com.apple.xpc.launchd[1] (com.mycompany.disable_wifi): Service only ran for 0 seconds. Pushing respawn out by 10 seconds.
Oct 31 16:20:27 --- last message repeated 2 times ---
Oct 31 16:20:27 MALKiosk-22462 com.apple.xpc.launchd[1] (com.mycompany.disable_wifi): Service only ran for 0 seconds. Pushing respawn out by 10 seconds.
Oct 31 16:20:58 --- last message repeated 2 times ---
Oct 31 16:20:58 MALKiosk-22462 com.apple.xpc.launchd[1] (com.mycompany.disable_wifi): Service only ran for 0 seconds. Pushing respawn out by 10 seconds.
Has something changed in a recent OS that makes this folder change repeatedly like this? This seems excessive for this script and I wonder now if there's a better way to achieve this.
Thanks.
Solved! Go to Solution.
Posted on 11-05-2019 03:36 PM
So I figured out why the launchdaemon was running so often. My Wi-Fi disabling script wasn't doing a check whether it needed to turn power off. It just turned Wi-Fi power off every time it ran. This meant that every time the script was invoked it triggered the launchdaemon which ran the script again. Infinite loop. <facepalm>
I offer this as a cautionary tale for those who come after me.
Posted on 11-05-2019 03:36 PM
So I figured out why the launchdaemon was running so often. My Wi-Fi disabling script wasn't doing a check whether it needed to turn power off. It just turned Wi-Fi power off every time it ran. This meant that every time the script was invoked it triggered the launchdaemon which ran the script again. Infinite loop. <facepalm>
I offer this as a cautionary tale for those who come after me.