I am working on a script that uses Swift Dialog to prompt users who have been running their Macs for a long time to reboot. The script creates a launch daemon after getting user input from Swift Dialog. The user is offered a drop down menu with 4 options: Reboot Now, 1 hour, 4 hours, 1 day. The StartInterval for the launch daemon gets set based on the option the user chooses from the drop down menu. Users are allowed 3 deferrals which I track using a PLIST. After the time set in the StartInterval elapses, the user is able to choose a different option. This changes the StartInterval to a new value. I included a step in the script to bootout the launch daemon just before it gets deleted and replaced with a new one containing the new StartInterval. When the new launch daemon is installed, there's a step to bootstrap it. I see in the policy log that the bootout step is failing, which then leads to the bootstrap step also failing since the launch daemon is still running.
Boot-out failed: 5: Input/output error
Bootstrap failed: 5: Input/output error
I have written a lot of scripts that bootout and bootstrap launch daemons so I'm confused why this isn't working. What's the best way to unload, delete, and replace a launch daemon or change its StartInterval and have the new one take effect?