Simple Cronjob for Directory Backup

I know this seems pretty trivial, but I don't see it working in a cronjob.

I run

zip -r /backup/$(date +'%Y%m%d').zip /var/www 

It works great. This gives me a zip file in my backup directory.

But I will open the Cron tab with

 crontab -e 

And I add this to the bottom of the file so it updates daily.

It doesn’t work here.

What am I doing wrong?

Edit: crontab looks like

 0 1 * * * /home/serveradmin/backup.sh 
+4
source share
1 answer

In cron, the % (percent) character must be escaped. You should comment on the percent signs with \ (backslash) in front of them. i.e.,

date + \% Y - \% m - \% d - \% H - \% M

+4
source

Source: https://habr.com/ru/post/1414204/


All Articles