The system is running CENTOS 5.8, Apache 2.2.3, MySQL 5.0.95, PHP 5.3.3
We run mysqldump daily for a few databases. It's run via a php script called in crontab.
They are run at the same time and cause a spike in the server load. So I'm going to stagger the times that the dumps are called.
I was wondering if calling the commands directly in crontab:
0 3 * * * /usr/bin/mysqldump -u XXX -p XXX params db_name | gzip params > /var/www/backups/database/daily/daily-db_name-`date +\%d`.tar.gz
Or through a shell script to set variables.
Would be less of a load than calling a php script that uses exec():
exec( "/usr/bin/mysqldump -u XXX -p XXX params db_name | gzip params > /var/www/backups/database/daily/daily-db_name-`date +\%d`.tar.gz" );
I'm considering running a test, but wanted to check if this is a "no-brainer".
Ran some tests and the load with the different methods wasn't noticeably different. I guess it could make a difference for a different type of operation where there are a lot of processes involved.
The php file being used is tracked in our svn repository, so best to stay with that approach.