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.

1 Answer 1


The first example would be less of a load - it has fewer processes to spawn / start. Realistically, it may not be a visible lesser of a load, but in absolute terms, it is less.

  • I ran some tests after reading your answer. As you indicated, the difference wasn't notable.
    – codewaggle
    Dec 17, 2012 at 18:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.