title: MySQL dump CronJob
body: <p>I'm trying to create a cron that daily backups my MySQL slave. The backup.sh content:</p>
  
  <pre><code>#!/bin/bash
  #
  # Backup mysql from slave
  #
  #
  sudo mysql -u root -p'xxxxx' -e 'STOP SLAVE SQL_THREAD;'
  sudo mysqldump -u root -p'xxxxx' ng_player | gzip &gt; database_`date +\%Y-\%m-\%d`.sql.gz 
  sudo mysqladmin -u root -p'xxxxx'  start-slave
  </code></pre>
  
  <p>I made it executable by <code>sudo chmod +x /home/dev/backup.sh</code>
  and entered in to <code>crontab</code> by:</p>
  
  <pre><code>sudo crontab -e
  
  0 12 * * * /home/dev/backup.sh
  </code></pre>
  
  <p>but it doesn't work, if I only run in the command line it works but not in <code>crontab</code>.</p>
  
  <p>FIXED:
  I used the script from this link: <a href="https://stackoverflow.com/questions/19731148/mysqldump-doesnt-work-in-crontab?rq=1">mysqldump doesn&#39;t work in crontab</a></p>