I have a number of feature classes that are set to Truncate and Append. It works fine in ArcCatalog modelbuilder, it even works fine in Python. The problem is when I try to tell windows task scheduler (in windows server 2008 R2) to run the python script on a daily basis it always fails. If I put it in a batch file that tells the python script to run, it will run. But upon checking the data it is not correct. Some of my target features have the wrong record count. It's as if the python script fails when run through task scheduler. But it works fine if just double click on the python script.
Solved! Go to Solution.
Tom,
You can add it to your python script something like this:
import logging logging.basicConfig(filename='example.log',level=logging.DEBUG) logging.debug('This message should go to the log file') logging.info('So should this') logging.warning('And this, too')
Regards,
Tom
Greetings Tom,
I have a few python scripts that I run nightly too. I have put most of them into bat scripts, but python should work too. When you create the task, which user have you specified to run the task? Do they have permission to all of the resources that are needed to be able to complete the task? It may also be helpful to add some logging to your scripts to see what is happening too.
Regards,
Tom
Thank you for the reply Tom. I haven't figured out how to add logging. I tried to add a line to the batch file with >>logfile.txt but it did not work.
Tom,
You can add it to your python script something like this:
import logging logging.basicConfig(filename='example.log',level=logging.DEBUG) logging.debug('This message should go to the log file') logging.info('So should this') logging.warning('And this, too')
Regards,
Tom
Thank you Tom. I added another line
logging.error('error', exc_info=True)
to trace back the error as well.
Tom,
Excellent! Glad you got it working!
Regards,
Tom
What seemed to work was to leave the server logged in. I lock it and close out of the remote desktop window. It works that way.