Select to view content in your preferred language

How do you update on a daily basis? Any alternative to Task Scheduler?

4138
6
Jump to solution
06-17-2015 08:36 AM
TomMagdaleno
Frequent Contributor

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. 

0 Kudos
1 Solution

Accepted Solutions
TomSellsted
MVP Regular Contributor

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

View solution in original post

6 Replies
TomSellsted
MVP Regular Contributor

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

TomMagdaleno
Frequent Contributor

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. 

0 Kudos
TomSellsted
MVP Regular Contributor

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

TomMagdaleno
Frequent Contributor

Thank you Tom.  I added another line

logging.error('error', exc_info=True)

to trace back the error as well.

0 Kudos
TomSellsted
MVP Regular Contributor

Tom,

Excellent!  Glad you got it working!

Regards,

Tom

0 Kudos
TomMagdaleno
Frequent Contributor

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.