I am trying to create a crontab to do a backup to my database in MySQL, the mysqldump
command works fine with no errors as a single command or running bash script, but when I added the bash script to the crontab file it did not execute, below is my code:
#!/bin/bash
mysqldump --column-statistics=0 -h xx.xx.xx.xxx -u wissam -p'xxxxxx'
--all-databases | gzip > ~/Desktop/DBs/Backup"$(date +"%Y_%m_%d_%I_%M_%p")file.sql.gz"
the crontab command:
09 9 * * * root sh /home/ahmad/Desktop/DBs/mysqlcron.sh 2>&1>> /home/ahmad/Desktop/DBs/MySQLdump.log
which was added to /etc/crontab
, after that I tried to restart the service but did not work for me, I also tried these solutions 1, 2 and 3 and still did not working.
Any help, please?
>> /home/ahmad/Desktop/DBs/MySQLdump.log 2>&1