Append current date to the filename via Cron


I've created a Cron task at my webhost to daily backup my database and I would like it to append the current date to the filename.

My Cron job looks like this

mysqldump -u username -pPassword db_name > www/db_backup/db_backup+date%d%m%y.sql

But the file I get is this: db_backup+date no file extension or date.

I've also tried this command

mysqldump -u username -pPassword db_name > www/db_backup/db_backup_'date +%d%m%y'.sql 

but that doesn't even give an file output.

What is the right syntax for getting the date appended to my file??

Best Solution

* * * * * echo "hello" > /tmp/helloFile_$(date +\%Y\%m\%d\%H\%M\%S).txt

You just need to escape the percent signs.

Other date formats: