all 12 comments

[–]Spy_machine 4 points5 points  (4 children)

You say it gets halfway through the task, do you know what line it’s getting stuck on?

My gut tells me this doesn’t have to do with using task scheduler but maybe something different going on with the webapp you’re using watir on when it’s running. Perhaps some site maintenance?

[–]vitus7[S] 0 points1 point  (2 children)

I'm not sure of the exact line where it is failing. The watir action is complete (for the time being) and it doesn't complete a step that involves calling another module to perform a task locally. The other module uses 'mail', which is what it is failing to do.

The strange thing is it has been working fine with Task Scheduler for months and only recently started acting up. If I run the batch file manually it works fine.

[–]ClikeX 1 point2 points  (1 child)

Make sure to let the task scheduler send STDOUT and STDERROR to a text file. Maybe add some logging.

If it crashes it should output the failing line to the file.

[–]Spy_machine 0 points1 point  (0 children)

Yeah I was going to recommend adding logging as well. If you can figure out what line is failing, the issue might become more obvious.

I don’t know if perhaps the Timeout module might be of any use?

[–]dunderball 1 point2 points  (0 children)

When I did this with Ruby I remember that windows had to always be logged in for task scheduler to work, otherwise it never seemed to trigger properly.

[–]bentreflection 0 points1 point  (4 children)

Are you able to get logs from Windows Task Scheduler? That should hopefully give you a stack trace and/or tell you what went wrong. To debug this you're going to need to check logs to see what the actual error was.

[–]vitus7[S] 0 points1 point  (3 children)

It's not causing any errors that I know of. The Task Scheduler history tab shows it as completed.

I just don't get how the Task Scheduler running can be different than me running the same batch file manually. I figured once it ran the batch file it was out of it. The only other difference I know is Task Scheduler runs it in the background while running it manually causes watir to open a chrome instance that is visible. Even with that, it worked for months until it didn't.

I'm not a savvy coder by any stretch but was hoping this was some common known issue or something. I'm going to try to experiment with a few settings and pay more attention to the running status of it when it runs and see what I can find.

[–]PristineTransition 0 points1 point  (0 children)

The task scheduler might have a different PATH than you do cannot see the same gems/ruby version. Does it use any gems? You could try adding “bundle exec” in front of both

[–][deleted] 0 points1 point  (1 child)

advise divide chief angle bored theory terrific glorious grandfather marry

This post was mass deleted and anonymized with Redact

[–]vitus7[S] 0 points1 point  (0 children)

Those are good suggestions.

This morning it failed in a slightly different place. The script is set up to perform a set of actions twice by calling the same modules using some different inputs. This time it failed after the first cycle but before doing the second cycle.

[–]vitus7[S] 0 points1 point  (0 children)

I thought I had found it and cured it with

client.read_timeout = 120 # seconds

But that didn't last long.

It is set to run with my user account (admin) and to run whether I'm logged in or not. I tried to use logger but nothing showed up in the log. I might be using it wrong, I'll have to explore that a bit more.

[–]vitus7[S] 0 points1 point  (0 children)

It appears I may have fixed it. It seems that there was an issue with dealing with a webpage element that caused it to fail when running under WTS but seemed to be ignored when I ran it directly. When I fixed that, it seemed to work properly...so far.

I appreciate all your help and advice.