Posted on 03-09-2015 12:14 PM
Hello, thank you for looking at my post. I have been working on the issue with /Private/Var/Folders growing in size. I took another members advice and am currently using this script:
#!/bin/sh
userList=`dscl . list /Users UniqueID | awk '$2 > 1000 {print $1}'`
echo "Deleting mobile accounts…"
for u in $userList ; do
dscl . delete /Users/$u
done
echo "Deleting all user cached files…"
rm -f -R /private/var/folders/*
shutdown -r now
I have created a Smart Group that records all MacBook Airs with less than 60GB of storage available and created a policy to run the above script on logout. If I leave the script "as is" it works fine. It removes what I need and reboots the machine. My only concern is under the "Logs" it states "Pending". If I remove the reboot command and execute the policy again the log shows "Completed". I'm pretty sure Recon is not running and submitting the information back to our JSS before the machine reboots. Is there an effective way for the script to wait for recon to finish and then reboot so the logs show "Completed" ?
Any advice is much appreciated. Thank you in advance.
Solved! Go to Solution.
Posted on 03-10-2015 05:15 AM
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
Posted on 03-09-2015 12:35 PM
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)
Posted on 03-09-2015 12:48 PM
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.
Posted on 03-09-2015 01:32 PM
could you just set the "update inventory" check box in maintanence options and set the restart options in the policy to force the reboot?
Posted on 03-09-2015 01:36 PM
I must be missing something, why are you rebooting on logout?
Posted on 03-10-2015 05:04 AM
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.
Posted on 03-10-2015 05:15 AM
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
Posted on 03-10-2015 05:46 AM
@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 !