Jump to content

Help with script that runs at specific time


Go to solution Solved by Alex037,

Recommended Posts

Hello everyone,

I was looking for an addition to a current script that runs daily. Due to the constrains on servers (tasks that run between 2AM and 7AM), I now have to modify the current script to run differently. I got it to work while it is on the same day (starts and finishes at the same day), but now I have to span it across days. For example, it has to be started somewhere between 14.00 and 18.00 (it is operators decision) and it will continue to run until 2AM next day. Then pauses, and continues after 7AM. According to the past work history, it will finish around 9-10AM, so there is enough time to verify data and prepare for the next run.

Thanks in advance.

Link to comment
Share on other sites

  • Solution

I have never used date function until now. Playing with examples to figure it out.

Idea is to record current date at the beginning of the script, set new variable that will add 1 day. At the end of every script iteration it should check if  $sNewDate is equal to $sDate (so it is past midnight, right), and then to check for current time. If the current time is greater than 2AM, pause until 7AM. So far I am getting zero as result.

#include <Date.au3>
#include <MsgBoxConstants.au3>

Local $sDate = _NowDate()
Local $sNewDate = _DateAdd('d', 6, _NowCalcDate())
Local $iDateCalc = _DateDiff('d', $sDate, $sNewDate)
MsgBox($MB_SYSTEMMODAL, "", "" & $iDateCalc)

Ok, I got it somehow to show difference. Error was in _DateDiff

#include <Date.au3>
#include <MsgBoxConstants.au3>

Local $sDate = _NowDate()
Local $sNewDate = _DateAdd('d', 2, _NowCalcDate())
Local $iDateCalc = _DateDiff('d', $sNewDate, _NowCalc())
MsgBox($MB_SYSTEMMODAL, "", "" & $iDateCalc)

This now shows -2 as a result.

Edited by Alex037
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...