After looking at the SchTasks.exe documentation here, it would be much cleaner to just
SchTasks /Create /TN "Periodic-Restart" /TN "shutdown /r /t 0" /sc weekly/mo 1 /st 00:00 /f
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi
What is the easiest way to auto restart a raspberry pi 3 once a week?
After looking at the SchTasks.exe documentation here, it would be much cleaner to just
SchTasks /Create /TN "Periodic-Restart" /TN "shutdown /r /t 0" /sc weekly/mo 1 /st 00:00 /f
Create a powershell script which schedules itself again in three weeks and then calls 'shutdown /r /t0'.
Your script could be something like:
$schdTime = [DateTime]::Now.AddDays(7)
$sts = $schdTime.ToString("MM/dd/yyyy")
$taskToRun = "powershell -command " + $Script:MyInvocation.MyCommand.Path
SchTasks.exe /Create /RU "SYSTEM" /SC ONCE /TN "Periodic-Restart" /TR $taskToRun /SD $sts /ST "00:00" /F
>
shutdown /r /t 0
Cron is a tool for configuring scheduled tasks on Unix systems.
How to schedule a job is explained here
So scheduling a reboot is possible too. I recommend wrapping the actual shutdown command in a shell script (with the right execution rights using 'chmod'). This way you are more flexible in what is executed (and you can add multiple commands which are executed in one go.)
Executing your script at 12:00AM on the first of every month looks like:
0 0 1 * * /etc/yourscripts/rebooteachmonth.sh