Schedule reboot of Linux VM for every other Tuesday (or every 14 days)

Adam Joseph 0 Reputation points
2023-03-23T10:38:35.5666667+00:00

Hi 

Is it possible to schedule reboots of a Linux VM every other Tuesday at 5.15am? 

Even if I use auto shutdown/startup, I can't see how to schedule this for every 14 days.

 Thanks

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,157 questions
Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,124 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Michael Durkan 12,151 Reputation points MVP
    2023-03-23T11:04:11.4166667+00:00

    Hi

    the default auto-shutdown won't do this, but you can create a Stop-AzureVM runbook, using Azure Automation and PowerShell and use the Azure Automation schedules to do that.

    https://learn.microsoft.com/en-us/azure/automation/overview

    https://learn.microsoft.com/en-us/azure/automation/shared-resources/schedules

    Hope this helps,

    Thanks

    Michael Durkan

    • If the reply was helpful please upvote and/or accept as answer as this helps others in the community with similar questions. Thanks!
    0 comments No comments

  2. Bjoern Peters 8,781 Reputation points
    2023-03-23T11:59:40.7333333+00:00

    Hi Adam

    Welcome to Q&A Forum; this is a great place to get support, answers, and tips.

    Thank you for posting your question; I'll be more than glad to help you out.

    Just a simple reboot of a Linux server?

    Why not use built-in crontab for this?

    sudo crontab -e
    

    Insert a line like

    0 5 * * 2 /sbin/shutdown -r +15
    

    This line will reboot your server EVERY Tuesday, for bi-weekly, it gets a little bit more complicated.

    0 5 * * Tue [ $(expr $(date +%W) \% 2) -eq 1 ] /sbin/shutdown -r +15
    

    I hope my answer is helpful to you, Your Bjoern Peters

    If the reply was helpful, please upvote and/or accept it as an answer, as this helps others in the community with similar questions. Thanks!

    0 comments No comments