0

I have 2 crontab commands.

The cron below works fine:

00 19 * * * cp -a /home/kmportal/VirtualBox\ VMs/cyn.in-disk1.vmdk /media/windowsshare

The cron below does not work after I add the time behind:

05 09 * * * cp -a /home/kmportal/VirtualBox\ VMs/cyn.in-disk1.vmdk /media/windowsshare/'date +%Y%m%d%H%M%S'cyn.in-disk1.vmdk

Please guide me to understand the command and how to solve.

Michael Berkowski
  • 267,341
  • 46
  • 444
  • 390
ash
  • 15
  • 1
  • 7
  • possible duplicate of [date +"%Y-%m-%d" in crontab](http://stackoverflow.com/questions/21749305/date-y-m-d-in-crontab) – fedorqui Jul 25 '14 at 08:23

1 Answers1

0

You should enclose the date command with ` instead of ' and escape the % characters

Try this:

05 09 * * * cp -a /home/kmportal/VirtualBox\ VMs/cyn.in-disk1.vmdk /media/windowsshare/`date +\%Y\%m\%d\%H\%M\%S`cyn.in-disk1.vmdk
Mohammad
  • 111
  • 5