Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Ive created a batch file to create a dump of a database and save it in a file with the current date as part of the file name. The batch file works brilliantly and all the data is saved correctly.

Ive now tried to set up a scheduled task to do this weekly, but ive run into a problem, although the task runs, the file it creates is empty, as if it has not pulled any data from the remote database. I know its pretty vague, but can anybody tell where id start looking for a reason/solution?

** EDIT **

Right, more progress - looks like it might be a path problem ive put a pause in the batch file, and when run through the task scheduler, it says:'mysqldump is not a recognized program'. However when run through the command line on my user account it works fine, just to confirm, ive set it run on the same user account ive been testing it on.

** EDIT 2 **

Ive found a sort of solution: ive had to refer the mysqldump application by its absolute path. However i still cant understand why it can find mysqldump from the path when run directly from the command line, but not when automated through the task scheduler

share|improve this question

2 Answers 2

Maybe the network was unavailable ? You could try scheduling it to run every 5/10 minutes, and see if the commands / variables are going correct. You sure that the script runs correctly when run as a whole and not just single command at a time ?


On your edit 2: Seems like mysqldump is not present in the PATH environment variables. Try adding that, and try again.

share|improve this answer
    
its not a network problem, i can run the entire batch file from the command line and it works ok, and i get the same problem trying to back up from my local mysql server –  richzilla Nov 1 '10 at 22:56
    
yep this is the problem, it is in the path. in the path ive got c:\xampp\mysql\bin` where bin contains all of the mysql binaries. when running the batch file from the command line, i just need to refer to the application name - mysqldump`. When running from the task scheduler, it refuses to work unless i provide the batch file with the full path to mysqldump.exe –  richzilla Nov 1 '10 at 23:46

Have you tried running mysqldump (in your scheduled task) in verbose mode? (--verbose)

Also, perhaps look at what user your task is running as, make sure that user has permissions to run mysqldump and create a file in the target directory.

share|improve this answer
    
The user the task is running as is the same as the user folder all the files are concerned with, so it shouldnt be a permissions problem. –  richzilla Nov 1 '10 at 22:57
    
Ive tried the verbose flag, again it works fine if i run batch file from the command line, but if i run it from through the task scheduler,a command prompt flashes up and then immediately dissappears, i never get a chance to see what it says. –  richzilla Nov 1 '10 at 23:03

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.