Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a number of batch files, which all work when ran separably to back up various Postgres dbs across the network. However when ran through task scheduler the backup files aren't created. There are no job warnings or errors, nothing to indicate anything is wrong except that the files don't exist. There is nothing in the event logs either.

So how can I work out what is wrong and fix it, what should I look at first?

share|improve this question
    
Have you checked the logs? I'm assuming you're using Windows Server 2003 since it's Scheduled Task and not Task Scheduler. You should be able to go to Advanced at the top and View Log. Also double check the credentials. –  Nixphoe Aug 3 '11 at 14:21
    
No, it's Task Scheduler - using 2008. I'm looking in the history and event logs. There is no Advanced option. Credentials checked. –  Mr Shoubs Aug 3 '11 at 14:51
1  
Try using exact path names and assume the PATH environment variable is empty or contains minimal entries. –  Ben Pilbrow Aug 3 '11 at 14:51
    
I do already. Adding the answer below. –  Mr Shoubs Aug 3 '11 at 15:15

1 Answer 1

up vote 3 down vote accepted

The only way I could find out what was going on is to add the following to the end of each line of the batch file:

>> C:\log.txt 2>&1
share|improve this answer
    
Certainly - you're writing a program, it should have debugging within it if you need to know what it's doing wrong. You didn't see anything wrong in the logs because the task didn't have a problem running the script - the script wasn't doing what you wanted, which is not an error from the OS perspective. –  mfinni Aug 3 '11 at 15:20
    
Don't forget to accept your own answer. –  mfinni Aug 3 '11 at 15:21
    
I can't accept it for a couple of days. :/ I think your correct, though as the script had a error ( pg_dump: [custom archiver] could not open output file "U:\VersionStore\versionstore.dump": No such file or directory The system cannot find the drive specified. )... I would have thought the scheduler would have picked that up. –  Mr Shoubs Aug 3 '11 at 15:26
    
I'm guessing your trying to used mapped drives...that's not going to work. Also, the scheduler isn't going to catch errors in your script (that is your job). It will just report back the final errorlevel. –  Doug Luxem Aug 3 '11 at 15:31
    
It doesn't report back anything other than success. see this question: serverfault.com/questions/297160/… –  Mr Shoubs Aug 3 '11 at 15:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.