Yes, your script is rebooting the Mac before the policy has had a chance to close out, perform a recon and submit inventory, just as you guessed.
You could try this - disable the submit inventory option within the policy itself and instead include jamf recon in the script after the rm -f -R and before the shutdown commands. So it would look something like this:
rm -f -R /private/var/folders/*
jamf recon
shutdown -r now
This will run the recon, complete and upload the log and then reboot immediately. Keep in mind this will slow down the logout a little since it can take a few seconds or so for recon to run and submit the log. How much it will get delayed depends on how much you're collecting in inventory (inventory collection options, Extension Attributes, etc)
On second thought, the above may not actually work either because the policy will still want to update the JSS that it completed a run, not just submitted inventory. If you try the above and it still doesn't work, the only thing I can suggest is to set the reboot to happen but with a delay and push it into the background so the script itself can finish out and thus the policy can complete and inform the JSS it completed.
The one issue with this is, the shutdown command only accepts two types of delayed time formats. In +n, which is in minutes, or an exact time in yymmddhh format. Neither are exactly ideal, but you could use either one to specify a reboot 30 secs or 1 minute in the future.
could you just set the "update inventory" check box in maintanence options and set the restart options in the policy to force the reboot?
I must be missing something, why are you rebooting on logout?
Thanks for your great responses.
@mm2270 I will try your suggestion of turning it off under maintenance and including it in the script.
@jchurch I can try this as well. Leaving it up to the policy to reboot.
@alexjdale When I remove the entire private/var/folders/ you have to restart before anyone else can log in. If not the user may experience some quirkiness such as no dock or cannot print since some important cache files are stored there. The folder would continue to grow after I removed everything and rebooted. The user accounts on the machine (maybe 125) were causing it to grow exponentially immediately after wiping p/v/f and rebooting. It would go from 40MB to 10GB in 2 minutes. Traced it down to an icon service creating icons for every user putting heavy load on CPU and causing folders to just grow like crazy.
Hi @Chuey,
If you want to update inventory and reboot the machine, but still have the policy logs submitted to the JSS, try this in your script instead:
jamf recon
jamf reboot -background -immediately
This will force the reboot as intended, but still send the policy logs to the JSS.
Hope that helps!
-Kitzy
@johnkitzmiller Just tried your suggestion and it worked exactly how I need it to and logs are successfully submitted to the JSS. Thanks a lot for your help it's much appreciated !