Launchd unloading LaunchDaemon I have a script scheduled to run as LaunchDaemon. Script runs fine when launched manually through terminal. 

I have two commands

sudo launchctl unload -F /Library/LaunchDaemons/com.test.plist
sudo launchctl load -F /Library/LaunchDaemons/com.test.plist


plist below

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com  
 /DTDs/PropertyList-1.0.dtd"&gt;
 &lt;plist version="1.0"&gt;
 &lt;dict&gt;
  &lt;key&gt;Label&lt;/key&gt;
  &lt;string&gt;com.test.plist&lt;/string&gt;
 &lt;key&gt;Program&lt;/key&gt;
 &lt;string&gt;/usr/local/bin/test.sh&lt;/string&gt;
 &lt;key&gt;StandardErrorPath&lt;/key&gt;
 &lt;string&gt;/tmp/com.test.plist.err&lt;/string&gt;
&lt;key&gt;StandardOutPath&lt;/key&gt;
&lt;string&gt;/tmp/com.test.plist.out&lt;/string&gt;
&lt;key&gt;StartCalendarInterval&lt;/key&gt;
&lt;dict&gt;
    &lt;key&gt;Hour&lt;/key&gt;
    &lt;integer&gt;18&lt;/integer&gt;
    &lt;key&gt;Minute&lt;/key&gt;
    &lt;integer&gt;4&lt;/integer&gt;
&lt;/dict&gt;





when run separately they do work. But once scheduled in launchd it runs for split second them goes to unloaded. I am guessing once it unloads the script it stops running. I change the values of the intervals set in the plist with another script which is why I need to unload and load. Is there another way to do this?
Is the problem perhaps that your unload command hasn't finished before the load command starts?

How about trying kickstart instead? "-k" instructs launchctl to "kill the running instance before restarting the service."


  sudo launchctl kickstart -k /Library/LaunchDaemons/com.test.plist


Note that load and unload are now under "Legacy commands" in the Yosemite launchctl man page.