Wednesday 23 August 2017

Task Scheduler - Runs manually but not on schedule.

Recently I was working on the automation scripts with the help of task scheduler. I created a task which runs a batch file on a time interval of 5 min. It was windows server 2016 environment. At initial it was all working fine. The batch script was working and running through scheduled task. To make some modification I disabled task scheduler and enabled it back when all my changes are set up. Since then it stopped working. I tried almost everything but could not find the reason why it has stopped running suddenly.Also there were no events, no errors, the status of last run showed time details is the reason the issue can not be traced easily.

After my few findings I figured it out that there is something to do with time. So here is the solution based on my findings and experiments. Every time you modify or disable/enable task scheduler you will have to set the time in future. E.g. you have scheduled the date in 'Start' such as 8/10/2017 with time 09:00 am.  as below..




and you will be setting it to run every 5 min in a day. You will see it is working all fine. However the next time you make the changes in Task Scheduler you will have to set the future date and time. Suppose you made the changes at 08/10/2017 09:10 am, you will require to change the time details to 08/10/2017 09:05 am considering the 5 min interval.
Hope it saves a day!