I have a policy that currently runs once a day that nags the end user to reboot.
Many of the users within the fleet have uptime greater than 30 days.
It prompts them on-screen to reboot - and if they dismiss it runs once the next day.
Sadly this doesn't seem to be enough of a nag.
Is there a way to execute a policy two or three times a day?
# Script to make the user aware that a restart has not occurred in over 7 days
# Use JamfHelper tool to show alert message
jHelper="/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper"
# Set maximum days to 30 before warning about restart
maxDays="30"
# Check to see if the machine has restarted in the last day
# See if "days" exists in the uptime
upTime=`uptime | grep "days"`
if [ -z "$upTime" ];
then
echo "Not yet one day"
exit 1;
else
echo "More than one day"
fi
# Get current uptime
upTimeDays=`uptime | awk '{print $3}'`
# Display uptime
echo "Uptime days: $upTimeDays"
# Advise user of uptime and give the option to reboot
msg="Your Highmark Mac has not been restarted for at least $upTimeDays days.
Please restart today in order to maintain the smooth operation of your system.
This message will repeat daily until a reboot has been performed"
# Location of icon
icon="/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertNoteIcon.icns"
# If uptime is equal to or greater than 130 days then display message
if [ "$upTimeDays" -ge "$maxDays" ]; then
echo "Mac has been up for more than $maxDays days"
# Get answer from user
result=`"$jHelper" -windowType utility -description "$msg" -title "Mac Desktop Support Notification" -button1 "Restart now" -button2 "Not yet" -defaultButton 2 -icon "$icon" -iconSize 90`
# If answer is Restart now, then restart
if [ $result -eq 0 ];
then
echo "I am rebooting...."
reboot
else
# Else delay restart
echo "Not yet..."
exit 0
fi
else
# Mac has been restarted within 30 days
echo "Mac has been up for less than $maxDays days. Exiting."
exit 0
fi