task scheduler and cron not working, but works otherwise...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

task scheduler and cron not working, but works otherwise...

Post by Burrito »

I have a simple task I've set up to dump my database every week then compact it to a gz file, here is the php that does it:

Code: Select all

<?
set_time_limit(0);
$now = date("m-d-Y",time());
exec("d:\\mysql\\bin\\mysqldump -u root -pmypassword mydatabase > d:\\backups\\data-".$now.".sql"); 
echo "backup has been done";
exec("tar -cf data-".$now.".tar data-".$now.".sql");
exec("gzip -9 data-".$now.".tar");
unlink("data-".$now.".sql");
?>
this worked fine using task scheduler on my old machine (php 4.3 on windows 2000). Now for some reason it dies when using task scheduler or cron after the data dump is complete (it doesn't do the tar or the gzip portion). If however I run it from the command line manually, it works fine, it also works fine if I hit it from the web. It's only when I use cron or task scheduler that it doesn't work. I really don't want to have to do this every week manually so any insights you can think of to help me fix this in either cron or task schduler would be appreciated. The environment is the same as what it worked on before other than I have php 5 on my new machine (but still windows 2000)

edit: I tried removing the echo thinking that might have been causing it to bomb, but still doesn't work....
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

got it working with chdir()....

weird that I didn't have to do this on my other machine 8O
Post Reply