0

Yesterday I spent several hours of my life which I'll never recover finding that, to my great surprise, W10 TaskScheduler is, apparently, crap.

I had two repeating tasks, both intended to do backups using a snapshotting mechanism provided by a brilliant backup app called restic. My restic commands are being run from a Python script, which is itself called from a .bat file, which is the thing that these tasks were asked to run repeatedly.

One task was repeating every 10 minutes, to do a snapshotting pattern to an internal HD, and another task was repeating ever hour, to do a snapshotting pattern to an external HD. They were both using the same Python script file.

Before I decided that I wanted to run these jobs "hidden", i.e. with no command prompt window flashing up each time the jobs ran, I seemed to have no problem running these commands in parallel: they were both logging to the same log file and had no problem doing that. Occasionally they would both want to log at the same moment and this would cause Python's logging module to issue a complaint to stderr, which I was directing to a special stderr file. But this occurrence didn't interfere with the running of the jobs.

Naturally enough, I eventually set both tasks to run "hidden". From that point forth I ran into all sorts of problems, seemingly no matter what I did. I got them to run separate .py programs. And separate .bat scripts. And to output stderr to different files. I changed the setting "If the task is already running, then the following rule applies" from "Do not start a new instance" to "Run a new instance in parallel". I set "If the task fails, restart every:" to "1 minute" and "Attempt to restart up to:" to "10" times. And more.

No matter what I did, one or other of these tasks would then fail, usually the hourly task. I had enabled the history in TaskScheduler for these tasks, and mostly this history would say "Launch failure"... but sometimes it would claim that the task started and ended (a giveaway being that it started and ended in the same second), but there would be absolutely no trace of them in the stderr file, or from the special echo commands I had inserted in the .bat file, or in the log file from the Python script.

Once the "hourly" task ran at startup (trigger for both tasks), and then didn't run the next hour, and then did run the hour after that. Without any messages or logging to explain why. My working hypothesis is that because the restic app is being run by both processes, TS considers this a problem, even though I have explicitly allowed more than one instance to run, and even though there were no problems when not running "hidden".

I believe I have exhausted all the options available in all the tabs of the properties for these tasks.

Occasionally in my life I have wanted to say something unkind to or about Microsoft, and often I have said it. My experience of using this heap of the proverbial this time has however not caused me too much grief or rise in blood pressure for the simple reason that I now expect this kind of thing. I'd have been surprised if this experience had actually worked out OK.

My "workaround" will henceforth be to have one Python "sys admin" script to coordinate absolutely everything going on in my system, i.e to act as a DIY cron file. I may in fact avoid TaskScheduler completely and just have this script run in the background from startup: the less reliant on the heap of proverbial that is W10, the happier for all concerned.

Am I being too unkind? Can anyone suggest something that went wrong here which I may not have considered? NB it may be of interest that this script has to run "as Admin" (i.e. the task settings "Run with highest privileges").

2
  • Do the tasks work reliable in hidden mode when you only enable one of both? Hence is it actually a concurrency problem of the two scripts or a python problem when running in hidden mode...
    – Robert
    Commented Mar 31, 2021 at 16:52
  • Good question: each runs fine when the other is disabled. Commented Mar 31, 2021 at 18:16

0

You must log in to answer this question.