Skip to main content

Hi All,



Here's my plist for a scheduled restart:



When I loaded this to one of my test machine it went on a restart loop. I want my kiosk machines to restart everyday on a specific time. Do I need to put in the Weekday key? How can I achieve this?



Thank you
Erwin

Something like this should work ( This restarts it at 10 PM, I also haven't tested this).



*Can you edit your script so it looks better, it's pretty cluttered and hard to look at right now



<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.org.shutdown</string>
<key>UserName</key>
<string>root</string>
<key>Program</key>
<string>/sbin/shutdown</string>
<key>ProgramArguments</key>
<array>
<string>/sbin/shutdown</string>
<string>-r</string>
<string>now</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>22</integer>
<key>Minute</key>
<integer>00</integer>
</dict>
</dict>
</plist>

Thanks @Abdiaziz ! 🙂 Will try this now and give you an update.


@Araneta No problem! Looking at your script, it restarts at 1:35 PM (using the 24 hour format). Are you sure you want it to restart during the day?



01:35 = 1:35 AM


Yup, I'm just testing the script with that time 🙂 (NZ time) I'll change it once I got it working properly.


Here's the updated script, tested it and it ran perfectly 🙂 Thanks @Abdiaziz. So I don't need to include RunAtLoad?



echo "<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.org.shutdown</string>
<key>UserName</key>
<string>root</string>
<key>Program</key>
<string>/sbin/shutdown</string>
<key>ProgramArguments</key>
<array>
<string>/sbin/shutdown</string>
<string>-r</string>
<string>now</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>14</integer>
<key>Minute</key>
<integer>35</integer>
</dict>
</dict>
</plist>" > /Library/LaunchDaemons/com.company.restart.plist

I don't, I put the .plist in /Library/LaunchDaemons. Give that a try @Araneta


Yup, it is already saved on that path :)
Thank you so much again @Abdiaziz . I can sleep soundly tonight. :)


@Araneta



You're welcome! A heads up, a restart will be needed to start the daemon.



This will work as well



#!/bin/bash
chown root "/Library/LaunchDaemons/nameof.plist"
chmod 644 "/Library/LaunchDaemons/nameof.plist"
launchctl load -w "/Library/LaunchDaemons/nameof.plist"

Did those too as well :)