Windows scheduled tasks fail with 0x1, don't log errors

2

1

I have three Python scripts running overnight as scheduled tasks on a Windows Server 2008 VM. I can run them manually with no problems. But when I look at the Task Scheduler each morning, the first has run successfully and the subsequent two returned 0x1. I added an exception handler to all three scripts to log the traceback, hoping to find the guilty operation. I tested the handler by manually raising an Exception which was working fine. However, when I checked the next day no log had been created, meaning the script either never ran or didn't actually throw an error. Can anyone shed any light on what exactly 0x1 means, or if there's a situation in which the script would run but still return that?

For what it's worth, this is the batch file that calls the script:

@echo off
"E:\Scripts\Backup\create_backup.py"

Rob

Posted 2013-03-18T18:08:20.690

Reputation: 289

4

A quick search seems to indicate that this can be caused by not specifying the correct working directory. When testing your setup, did you try to invoke the task execution through the task scheduler (there's a Run option for tasks in the library)?

– Der Hochstapler – 2013-03-18T18:11:19.600

1Oliver, thanks for the tip, that does sound exactly like what I'm experiencing. I updated the script path to exclude the current working directory, instead specifying it in "Start in". When I run the task nothing visibly happens in the scheduler (I would expect the status to be "Running..."), but eventually it completes. Thanks again! – Rob – 2013-03-18T19:33:02.673

Answers

0

Look like this problem outside of python. May be i wrong, but by default windows allow cmd.exe execution only for logged in user. To check, add diagnostic output to cmd script

echo Run %DATE% %TIME% >> c:/tmp/file.log

Mikhail Moskalev

Posted 2013-03-18T18:08:20.690

Reputation: 1 718