Scheduled restart raspberry pi windows iot

DeeJay1984 1 Reputation point
2020-08-25T16:38:44.457+00:00

Hi

What is the easiest way to auto restart a raspberry pi 3 once a week?

Windows for business | Windows for IoT
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Robin Holt 16 Reputation points
    2020-08-25T21:01:33.243+00:00

    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

    2 people found this answer helpful.
    0 comments No comments

  2. Robin Holt 16 Reputation points
    2020-08-25T20:14:46.803+00:00

    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

    1 person found this answer helpful.
    0 comments No comments

  3. Sander van de Velde | MVP 36,766 Reputation points MVP Volunteer Moderator
    2020-08-27T22:11:20.01+00:00

    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
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.