Skip to main content
Question

Make client MacOS devices restart after running for x days

  • October 29, 2019
  • 0 replies
  • 3 views

Forum|alt.badge.img+4

!/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