0

I'm implementing an automatic backup feature. I can run this command from the command line:

aws ec2 create-snapshot --volume-id=vol-abc123 --description=backup$(date +"%d-%m-%Y")

It creates a snapshot with a description like backup01-01-2017

But running this command through cron like:

0 0 * * *    aws ec2 create-snapshot --volume-id=vol-abc123 --description=backup$(date +"%d-%m-%Y")

It says:

/bin/sh: 1: Syntax error: Unterminated quoted string

If I remove the $(date +"%d-%m-%Y") from the command it works again:

0 0 * * *    aws ec2 create-snapshot --volume-id=vol-abc123 --description=backup

How can I make $(date +"%d-%m-%Y") to work from cron?

Pipe
  • 101
  • 1
    http://unix.stackexchange.com/questions/29578/how-can-i-execute-date-inside-of-a-cron-tab-job – jordanm Jan 06 '17 at 20:37
  • Thanks for the link @jordanm. The answer to my problem was % must be escaped with \ as: `$(date +"\%d-\%m-\%Y")`. – Pipe Jan 06 '17 at 23:14

0 Answers0