title: Creating a cron job for mysqldump
body: <p>I'm trying to create a cron job for database backup.</p>
  
  <p>This is what I have so far:</p>
  
  <p>mysqldump.sh</p>
  
  <pre><code> mysqldump -u root -ptest --all-databases | gzip &gt; "/db-backup/backup/backup-$(date)" 2&gt; dump.log
  
   echo "Finished mysqldump $(date)" &gt;&gt; dump.log
  </code></pre>
  
  <p>Cron job:</p>
  
  <pre><code> 32 18 * * * /db-backup/mysqldump.sh
  </code></pre>
  
  <p>The problem I am having is the job is not executing through cron or when I am not in the directory.</p>
  
  <p>Can someone please advise.  Are my paths incorrect?</p>
  
  <p>Also, the following line I'm not sure will output errors to the dump.log:</p>
  
  <pre><code> mysqldump -u root -ptest --all-databases | gzip &gt; "/db-backup/backup/backup-$(date)" 2&gt; dump.log
  </code></pre>
  
  <p>What worked:</p>
  
  <pre><code> mysqldump -u root -ptest --all-databases | gzip &gt; "../db-backup/backup/backup-$(date).sql.gz" 2&gt; ../db-backup/dump.log
  
   echo "Finished mysqldump $(date)" &gt;&gt; ../db-backup/dump.log
  </code></pre>