Make client MacOS devices restart after running for x days

duhkha9622
New Contributor

!/bin/sh

Set UPTIME output for echo

UPTIME=uptime | cut -d ',' -f 1

clip the number of days of uptime and set as variable Days

Days=echo $UPTIME | cut -d ' ' -f 3

Check that second step is cutting correct field

echo $Days

Set the max number of days of uptime to Parameter 4

RUNNING=$4

if [ $Days -gt $RUNNING ]

then

shutdown -r now

fi

0 REPLIES 0