> Hi I'm trying to create a script which my cron will run once a day to
backup
> my MySQL database, but the exec command doesn't want to work no matter
what I
> try...
Uhhhhh.
cron + PHP is cool, but using cron to run PHP to run mysqldump is kinda
silly... :-)
Just put the mysqldump line in your cron job, or create a "shell script" to
do what you need.
Basically, a shell script:
1. Starts with
#!/usr/bin/sh
(You can use any "shell" [bash, csh, ash, smrsh] instead of sh that feels
good.]
2. Has stuff you would normally type on the command line, like:
mysqldump -h localhost -u user -p pass --opt DataBase > BACKUPS/backup.mysql
3. Has permission to be run by one or more users:
chmod 700 backup.sh
You can then use /path/to/backup.sh as a command, or use that in a cron job.
> exec("mysqldump -h localhost -u user -p pass --opt DataBase >
> BACKUPS/backup.mysql") or die("Problem");
>
> I have tried adding the full path to mysqldump,
You need that.
> I have tried using my root
> access,
machine root, or MySQL root? The former is a BAD IDEA... The latter ain't
so hot either. Certainly don't be putting a script with database passwords
in your web-tree.
> I have tried using a different dir to store the files, changed
> permissions all sorts and nothing works. It always returns "Problem" and
if I
> take out the or die then it just returns a blank screen.
You can add more args to exec() to get more info about what went
wrong/right:
exec("...", $results, $errorcode);
while (list(,$line) = each($results)){
echo $line, "<BR>\n";
}
if ($errorcode){
echo "OS Error: $errorcode. Usually paths/permissions. Use 'man errno'
to look it up.<BR>\n";
}
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]