Reputation: 483
First, I created .my.cnf in /home/username/
with the following text:
[client]
user = sample_user
password = sample_password
host = localhost
Then, I executed the command below and it went successfully:
/usr/bin/mysqldump sample_table > home/username/backup_db/$(date +%F)_full.sql
But, when I entered it in crontabs, it didn't worked:
0 0 * * * /usr/bin/mysqldump sample_table > /home/username/backup_db/$(date +%F)_full.sql
I even tried changing the minutes and hour portion but still, it won't work.
Upvotes: 0
Views: 1232
Reputation: 1830
You need to escape the percent sign (%), as it has a special meaning in crontab entries, use \% instead.
Upvotes: 4