On my production websites, I have some code that runs via a cron job to backup the databases. This is working fine, and I want to set up the same thing (but more complex) on my own machine. The exec command that I have is fine, because when I echo it back and run it from command line (in the same directory as the script) it works. However when I run the exec command from php, it appears to do nothing (no backup, no error). Any ideas?
here's the code. As I mentioned, if I output the variable and run it in terminal, it works. the same command on my production server works. I've also tested running an exec("whoami") just to make sure exec is working in my php, which it is. I have error reporting set to E_ALL. The php user has read/write permissions to the directory I'm using. I don't have safe mode on or any disabled_functions set. Any ideas?
Code: Select all
$command = "mysqldump --log-error='error.txt' --user=$username --password=$password --single-transaction --host=$host --databases $database --result-file=$filePath"; exec($command, $return);