System restart notification via Swift Dialog

ScottEKendall
Contributor

Another script that grew out of necessity.  Trying to "encourage" users to restart their Macs at least once every 30 days to help with overall system performance, make sure all policies are installed, fix network related issues, etc. so I can with with this super simple Dialog notification that shows up once a week if they are in the "over 30 day uptime" smartgroup.  Users don't have to restart, but if they do, you can set a custom timer to do an automatic restart for them.  I used the AppleScript method of doing a restart so it will prompt the user to save their docs before a restart.  Script can be found here: https://github.com/ScottEKendall/JAMF-Pro-Scripts/tree/main/UpTime

Uptime.png

Regex I used to calculate 30+ days

Uptime_SmartGroup.png

And the script parameters...you can control the uptime days and timer value.

Screenshot 2025-05-05 at 11.37.43 AM.png

2 REPLIES 2

sdagley
Esteemed Contributor III

@ScottEKendall Thanks for sharing. One suggestion though... Instead of having an EA that converts the result of uptime into a number of days, use one that returns the date the Mac was last booted so Jamf Pro can use date logic for it as a Smart Group criteria (since the number of days won't be accurate if the Mac isn't reporting inventory in). This thread is where I found the EA I use for that: https://community.jamf.com/t5/jamf-pro/restart-computer-after-x-days-of-uptime/m-p/262581

ScottEKendall
Contributor

Excellent suggestion...thanks!