Kaseya Community

Schedule IT Procedure to run at predetermine time

  • Greetings,

    I am creating a script to run chkdsk if a monitor set detected an unexpected shutdown.

    The script will run chkdsk in read only mode. If an error is detected in the log output, I would like to schedule a reboot to happen at 2am.

    I haven't been able to schedule a secondary script to run at a predetermined time. I do have the option to wait X number of minutes but I would prefer a controlled time slot to run this job.

    Any ideas, other than building a script to create a schedule task on the workstation.

    Legacy Forum Name: Schedule IT Procedure to run at predetermine time,
    Legacy Posted By Username: ITRTech
  • How about running a procedure at 2am daily to check for the existance of the log and then parse it looking for the required output.If it find its it could then reboot the machine.

    Legacy Forum Name: IT Procedures,
    Legacy Posted By Username: PeterS
  • Well...Not exactly the most graceful solution but it will work.

    Thanks

    Legacy Forum Name: IT Procedures,
    Legacy Posted By Username: ITRTech
  • I dont believe that there is a way to shedule a kaseya script to initiate at a set time (i.e 2am) from within another script.

    Are you thinking this for workstations or servers?

    Instead of rebooting later when it might be too late....why not immediately initiate a script which informs the user that their system might be in danger of data corruption and that it needs to be rebooted/scanned immediately. You could put a xx minutes timeout on the dialog before auto initiating the reboot.

    Legacy Forum Name: IT Procedures,
    Legacy Posted By Username: XeviouS
  • You could use a VBScript to calculate the number of minutes until 2:00 am, then read this scripts' output and assign it a variable in a Kaseya script. Then, use this variable for the Execute Script entry for "Enter time delay before script executes." Then select Minutes for the entry for "Select time units or Immediate to execute script right away."

    Here a qucik and dirty VBScript that will calculate the number of minutes until 2:00 am. I wrote this very quickly, so please test:


    ' MinutesTo2.vbs
    ' Calculate the number of minutes until 2:00 am
    ' Run from command line and redirect output to a file:
    ' cscript MinutesTo2.vbs //nologo >OutputFileName.txt

    SecondsPastMidnightToCalc = 7200 'Checking for 2:00 am, or 7200 seconds past midnight
    SecondsPastMidnightNow = Timer() 'How many seconds have elapsed since midnight
    SecondsPerDay = 86400 'Seconds in a 24 hour period

    If SecondsPastMidnightNow

    SecondsToReturn = SecondsPastMidnightToCalc - SecondsPastMidnightNow 'Calculate Seconds Result
    Else

    SecondsToReturn = SecondsPerDay - SecondsPastMidnightNow + SecondsPastMidnightToCalc 'Calculate Seconds Result

    End If

    MinutesToReturn=int(SecondsToReturn / 60) 'Calculate in minutes - Return integer result

    Wscript.Echo MinutesToReturn 'Echo result in minutes


    Legacy Forum Name: IT Procedures,
    Legacy Posted By Username: pcmnetmanage
  • Hey no fair....using VBScript is cheating!

    ...fine then, I'm off to write this up in PowerShell.

    Big Smile

    Legacy Forum Name: IT Procedures,
    Legacy Posted By Username: XeviouS
  • An AT command should let you run something from a command prompt at 2:00am.
    This should allow you to do a restart, but NOT run a kaseya script.

    Legacy Forum Name: IT Procedures,
    Legacy Posted By Username: garry