Posted on 12-05-2023 11:48 AM
Hi,
Does anyone know how to set up a policy thta triggers every 2 montths (or a specific time)?
I want to set up a policy that tiggers a script that moves all of the files of the download folder to the trash (i already have the script), that is cus the computers are used by students that donwlaond multiple files for their projects, but rather that delete those files at the end of semestres y prefer to set up a policy that triggres the scrpit once every two months.
Is it possible?
Thanks in advance.
Posted on 12-05-2023 12:16 PM
Not natively in Jamf Pro. You can set a policy to run Once per Month, but not once every other month.
A solution would be to utilize a LaunchDaemon that ran on the schedule you want that simply used the Jamf binary to call a specific policy. The policy could be set to use a Custom trigger and set to Ongoing frequency. The LaunchDaemon would call the policy using that custom trigger.
Posted on 12-05-2023 02:49 PM
Another option if you don't want to run a cron job or launch daemon:
That's assuming you wanted every computer to get this policy; otherwise, you change your smart group to "AND [whatever your other criteria is]". You could also do something similar without saving a hidden file with a call to the API when your script finishes, but you'd have to put credentials in the script, which isn't ideal.
Posted on 12-05-2023 11:41 PM
Another way to do it (as these are all going to be slightly cludgy fixes) would be to clone the policy 5 times and set the scheduled dates at the set times throughout the year with each one switching off before the next enables.
Posted on 12-06-2023 06:10 AM
I was going to suggest something similar to what @mdp suggests above. Only difference is I would probably not capture the date of last execution as an Extension Attribute. I'd just code it into the script in the policy to first check for a last run date from the local file/plist, and if it has been 60 or more days since the last run, then it would continue. If it's less than 60 days, then just exit. You'll have to do a little math in your script, but it's fairly simple to do. Your policy can be set to run once per month, or perhaps once per week would make more sense. It should only then execute the rest of the script if the time since the last execution is 60 or more days, or whatever value you choose.