I try to backup a file in crontab but the date to save a specific folder
In crontab
crontab -e
* * * * * echo "hi i am safwan" >> /home/safwan/linx/backup/"$(date +"%Y_%m_%d").bak"
But no backup of the file.
What is the solution?
I try to backup a file in crontab but the date to save a specific folder
In crontab
crontab -e
* * * * * echo "hi i am safwan" >> /home/safwan/linx/backup/"$(date +"%Y_%m_%d").bak"
But no backup of the file.
What is the solution?
You use nested double quotes without escaping the inner ones.
This would work:
"$(date +\"%Y_%m_%d\").bak"
However, all these quotes are unnecessary. You can remove them all.
EDIT:
As pointed out in one of the comments to the original question, there is a second problem: % is special character in crontab, so you have to escape it:
$(date +\%Y_\%m_\%d).bak