windows scheduler not working

  • Thread starter Thread starter yawnmoth
  • Start date Start date
Y

yawnmoth

I'm trying to use Windows Scheduler to make a backup of a database on
my computer every day at 6am and am having some difficulty.

If I run the backup script manually, it works. If I tell the scheduler
to run it a minute or two from now (eg. 11:30am, when it's 11:28am) it
works. However, at 6:00am (after I've been asleep for a few hours), it
doesn't.

As for how I know it isn't working... the script pretty much creates a
zip file of the database backup and copies it over the network to
another computer. When I do it by hand (or a minute or two from now,
as described above), the timestamp on the file on the other computer
reflects this. Further, every time the file is ran, a note to this
effect is appended to a file - log.txt - making note of this (this note
includes the time and date the script was ran).

So, like I said, Windows Scheduler doesn't seem to be working, save for
in situations where manual backups are just as effective. Any ideas as
to what I can do to fix this?

Also, any ideas as to how I can better test whether or not it is
working? Thus far, all the tests I've attempted to use give me
(apparently) false results. However, being able to only run one test a
day is going to make this take much more time than I'd like it to...
 
What's the scheduler say under the "Last Run Time," "Next Run Time," and
"Last Result" columns?
 
Are you perchance logging off before the script runs? Your script may
be relying on your login credentials to work properly.
 
Leigh said:
Are you perchance logging off before the script runs? Your script may
be relying on your login credentials to work properly.

If I were logging off, wouldn't any open windows I have close? Since
this isn't happening (and since, whenever I move the mouse, I'm taken
immedietly to my desktop) I assume this isn't happening...
 
Ken said:
What's the scheduler say under the "Last Run Time," "Next Run Time," and
"Last Result" columns?

The "Next Run Time" column says "At 6:00 AM every day, starting
5/9/2006", the "Last Run Time" column says "6:00:00 AM 5/11/2006", and
the "Last Result" says "0x0".

I'm not sure what the Last Result of 0x0 means, but the "Last Run Time"
column is definitly wrong...
 
yawnmoth said:
The "Next Run Time" column says "At 6:00 AM every day, starting
5/9/2006", the "Last Run Time" column says "6:00:00 AM 5/11/2006", and
the "Last Result" says "0x0".

I'm not sure what the Last Result of 0x0 means, but the "Last Run Time"
column is definitly wrong...

6:00am came and went, again with no backup being made. I found a link*
which states that 0x0 means that the run was succesful. The log file
further corroberates this. However, both are very wrong. The batch
file that is supposed to be running is supposed to append stuff to its
own log file every time it is ran. It isn't.

Further, the timestamp on the file it produces should be updated. It
isn't.

So why would Windows Scheduler, for lack of a better word, lie?

* http://support.microsoft.com/?kbid=308558

Here's the batch script:

echo Starting run on %date% at %time% >> log.txt
mysqldump --opt -u "user" --password="password" database > backup.sql
"c:\program files\winzip\wzzip" backup.zip backup.sql >> log.txt
erase backup.sql >> log.txt
net use z: \\computer\uploads >> log.txt
copy backup.zip z: /y >> log.txt
net use z: /delete >> log.txt
echo Completed run on %date% at %time% >> log.txt

Here's the schedular's log:

"Database Backup.job" (backup.bat)
Started 5/12/2006 6:00:00 AM
"Database Backup.job" (backup.bat)
Finished 5/12/2006 6:00:03 AM
Result: The task completed with an exit code of (0).
 
yawnmoth said:
6:00am came and went, again with no backup being made. I found a link*
which states that 0x0 means that the run was succesful. The log file
further corroberates this. However, both are very wrong. The batch
file that is supposed to be running is supposed to append stuff to its
own log file every time it is ran. It isn't.

Further, the timestamp on the file it produces should be updated. It
isn't.

So why would Windows Scheduler, for lack of a better word, lie?

* http://support.microsoft.com/?kbid=308558

Here's the batch script:

echo Starting run on %date% at %time% >> log.txt
mysqldump --opt -u "user" --password="password" database > backup.sql
"c:\program files\winzip\wzzip" backup.zip backup.sql >> log.txt
erase backup.sql >> log.txt
net use z: \\computer\uploads >> log.txt
copy backup.zip z: /y >> log.txt
net use z: /delete >> log.txt
echo Completed run on %date% at %time% >> log.txt

Here's the schedular's log:

"Database Backup.job" (backup.bat)
Started 5/12/2006 6:00:00 AM
"Database Backup.job" (backup.bat)
Finished 5/12/2006 6:00:03 AM
Result: The task completed with an exit code of (0).

Your batch file logging method is good but you need to
tighten it up. As it is coded, you do not know where
the log files will be located. Modify it like so, then try again:

@echo off
echo Starting run on %date% at %time% >> c:\log.txt
mysqldump --opt -u "user" --password="password" database > c:\backup.sql
"c:\program files\winzip\wzzip" backup.zip backup.sql >> c:\log.txt
erase backup.sql >> c:\log.txt
net use z: \\computer\uploads 1>> c:\log.txt 2>>c:\log.err
copy backup.zip z: /y >> c:\log.txt
net use z: /delete >> c:\log.txt
echo Completed run on %date% at %time% >> c:\log.txt

Note the extra log file c:\log.err.

Note also that backup.zip and backup.sql must have
fully qualified path names. Modify your script accordingly!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top