Skip to main content
Solved

Why won't script continue after bootout command?


Forum|alt.badge.img+5

I have the following in a script on Jamf Pro. When I deploy the script and it runs this I can see on the test Mac it has "Attempt 1 to bootout com.Daemon" in the log file. 

However, it fails to continue with the rest of the script. I tried adding

|| echo "bootout error" 

after the bootout command but that didn't help either. When I run the launchctl list | grep "com.Daemon" command I can also see it has successfully booted out the Daemon. 

Why won't it continue to then trigger the jamf policy?
I've tried
/usr/local/bin/jamf policy -event 'Trigger'
I've tried with sudo and without. I've also tried to have it trigger the jamf policy first which works but if I put a delay in the policy so I wait until bootout is complete it doesn't progress to attempt bootout (it waits on policy completing). I tried adding & to then end (/usr/local/bin/jamf policy -event 'Trigger' &) and that resulted in bootout command running but jamf policy did not. 
When I run the script as sudo locally it works but not when it is launched via another script. I have another script which if a condition is met it runs

sudo /usr/local/.Hidden/Bootout1.zsh

 

cat <<"EOF"> /usr/local/.Hidden/Bootout1.zsh #!/bin/zsh --no-rcs # Jamf binary jamf="/usr/local/bin/jamf" bootlog_file=/usr/local/.Hidden/BootoutLogFile.log exec >> $bootlog_file 2>&1 Counter2=0 while launchctl list | grep -q "com.Daemon1" && [ $Counter2 -lt 5 ]; do (( Counter2 ++ )) echo "Attempt $Counter2 to bootout com.Daemon" sudo /bin/launchctl bootout system /Library/LaunchDaemons/com.Daemon1.plist sleep 2 done $jamf policy -event 'Trigger' EOF

 

 

Best answer by BriBri210786

I think I know the issue. The script was created by script which Daemon loads. I didn't think that would be an issue as done it this way deliberately to run process separate to script which is set to run every so often by the Daemon. 

I've managed to get a resolve it through use of extension attributes and scoping for the next policy to run. 

View original
Did this topic help you find an answer to your question?

3 replies

sdagley
Forum|alt.badge.img+25
  • Jamf Heroes
  • 3540 replies
  • March 23, 2025

@BriBri210786 A few issues with your script....

You don't need a sudo prefix for commands in a script being run via the Jamf binary on a Mac, they're already running as admin

Try this for your bootout command to unload the LaunchDaemon process:

sudo /bin/launchctl bootout system/com.Daemon1

(If your LaunchDaemon has a label use that)


Forum|alt.badge.img+5
  • Author
  • New Contributor
  • 2 replies
  • March 23, 2025
sdagley wrote:

@BriBri210786 A few issues with your script....

You don't need a sudo prefix for commands in a script being run via the Jamf binary on a Mac, they're already running as admin

Try this for your bootout command to unload the LaunchDaemon process:

sudo /bin/launchctl bootout system/com.Daemon1

(If your LaunchDaemon has a label use that)


I updated the script as you suggested.

cat <<"EOF"> /usr/local/.Hidden/Bootout1.zsh #!/bin/zsh --no-rcs # Jamf binary jamf="/usr/local/bin/jamf" bootlog_file=/usr/local/.Hidden/BootoutLogFile.log exec >> $bootlog_file 2>&1 Counter2=0 while launchctl list | grep -q "com.Daemon1" && [ $Counter2 -lt 5 ]; do (( Counter2 ++ )) echo "Attempt $Counter2 to bootout com.Daemon" /bin/launchctl bootout system/com.Daemon1. sleep 2 done $jamf policy -event 'Trigger' EOF

It has the same problem. When the this script executes this it still just shows "Attempt 1 to bootout com.Daemon" (the label is correct - com.Daemon1.. i checked this and it does boot it out) in the log file. On checking it has successfully booted out the Daemon but does not exit loop and run the jamf policy - event 'Trigger' command. 

I know it should run as sudo as run from Jamf Binary but tried with and without it. 

If I run this script locally as sudo it also works which I don't understand. 


Forum|alt.badge.img+5
  • Author
  • New Contributor
  • 2 replies
  • Answer
  • March 23, 2025

I think I know the issue. The script was created by script which Daemon loads. I didn't think that would be an issue as done it this way deliberately to run process separate to script which is set to run every so often by the Daemon. 

I've managed to get a resolve it through use of extension attributes and scoping for the next policy to run. 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings