Here is my question asked on StackExchange 2 days ago. https://stackoverflow.com/q/35839190/4772652 Someone suggested me to ask here. Could anyone give me a hand to solve this?


I had tried to launch a script of mysqldump for daily backup by launchd and also by Carbon Copy Cloner (CCC). The script works fine under command line. However, it comes with empty file under launchd or CCC.

While I manually ran the command sh mysqldump.sh, a <DATE>.sql.gz file will be created. And if the launchd/CCC called the script, a <DATE>.sql.gz file will also be created. However, the file size will by 2 0B.

Here is the content of my plist file

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">

And the launchd status for this plist is - 0 com.MySQL.crontab

Here is the script for mysqldump, which is created by Schulz with slight modified

# *************************************************************
# file: mysqldump.sh
# date: 2015-03-27
# author: (c) by Marko Schulz - <info@tuxnet24.de>
# description: Get a mysqldump of all mysql databases.
# *************************************************************


date=$( date +%Y%m%d )

find $dbBackup/ -mtime +30 -type f -name '*.sql.gz' -exec rm -rf {} ';' >/dev/null 2>&1

mysqldump -u $dbUsername --all-databases | gzip > ${dbBackup}/${date}.sql.gz 2>&1

What could I do to solve this problem?

  • Where is mysqldump? The probable issue is that it is not on the path for launchd although you have the /bin/mysqldump.sh in Apple's controlled area so I might be wrong – Mark Mar 9 '16 at 11:05
  • Is the path to the script actually /bin/mysqldump as the script shows? – Mikey T.K. Mar 9 '16 at 16:33

Your shell script is missing the full path to mysqldump (assuming you've installed MySQL Community Edition by Oracle):

/usr/local/mysql/bin/mysqldump -u $dbUsername --all-databases | gzip > ${dbBackup}/${date}.sql.gz 2>&1

If you need a password define it in the shell script:


and change the above line to:

/usr/local/mysql/bin/mysqldump -u $dbUsername -p$dbPassword --all-databases | gzip > ${dbBackup}/${date}.sql.gz 2>&1

There is no space between -p and $dbP...!

I also advice to move the shell script to another path (e.g. /usr/local/bin/). You have to adjust your plist then and the line




You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .