1

I am using Task Scheduler with automation tasks specifically with python. But I realize if my computer is close during execution time of the task, the next run time is automatically set the next date without error because the task is not run.

For example I arrange the task for every week and let us say that the task will be executed 29-Feb-2021 at 20:00. However if my computer is closed at this time, next run time automatically become 07-Mar-2021. Basically, there is no execution occur on 29-Feb-2021. The Last Run Time is shown as the previous week's execution time.

I have marked "Run task as soon as possible after a scheduled start is missed" but it didn't work. Because there is no schedule that is missed!

The task scheduler works just fine if my computer is open. I think I am missing something but I didn't find it.

2
  • Try in addition to "Run task as soon as possible" to also set "If the task fails, restart every:".
    – harrymc
    Commented Feb 28, 2021 at 20:58
  • I did but again It didn't work. I guess It didn't work because the task didn't fail. Last Run Result is successful. (The operation is completed successfully (0x0) ) But this result is the previous task, not the current tast.
    – malachi
    Commented Mar 4, 2021 at 20:21

1 Answer 1

0

Task Scheduler has no such option, so do your own.

Add at the end of the weekly job a command that will write a flag file whose date will mark the time at which the job was successfully run, for example:

echo abc >"C:\switch\switch.txt"

Then add another task that is scheduled to run daily (or after logon) that will delete the flag file if older than 10 days and then test if it still exists:

cd /d "C:\switch"
forfiles /m "switch.txt" /d -10 /c "cmd /c del @path"
if exist "C:\switch\switch.txt" (
    echo automated job was not skipped
) else (
    echo job skipped - running automated job
)
3
  • Actually, yes I did a similar thing. I create a csv file that keeps track of the successful runs. Additionally I increase the repetition times of the task in a day and it is better now. Thanks!
    – malachi
    Commented Mar 5, 2021 at 10:42
  • By the way, which language is this? Is it batch file? If so how can I learn this language? Do you have any suggestion?
    – malachi
    Commented Mar 5, 2021 at 20:03
  • This is the batch language supported by Windows CMD. A good compendium of all its commands is found at SS64. This is a very old language, rooted in DOS, so there is an enormous amount of information to be found.
    – harrymc
    Commented Mar 5, 2021 at 20:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .