0

I'm trying to schedule this command on crontab

00-59/1 * * * * s3cmd put $HOME/www/database.db s3://Solenoide/`date +%Y-%m-%d_%H-%M-%S`.db

It's a backup to AWS S3 using s3cmd. The command runs fine when I execute it on the terminal (Ubuntu 14.04 and Raspbian), but it doesn't work if I schedule it on crontab. The "date" part seems to be the cause, as I tested it with a constant name and it works.

What should I do so crontab execute this?

Vini.g.fer
  • 11,639
  • 16
  • 61
  • 90

1 Answers1

0

I figured it out using part of the answer from this post:

https://serverfault.com/questions/339814/how-do-you-set-a-date-variable-to-use-in-a-log-for-crontab-output

Turns out that crontab doesn't parse correctly as commands. In my case I needed to add a backslash before the % so it could understand the command correctly. The final schedule on crontab looks like this:

00-59/1 * * * * s3cmd put $HOME/www/database.db s3://Solenoide/`date +\%Y-\%m-\%d_\%H-\%M-\%S`.db
Community
  • 1
  • 1
Vini.g.fer
  • 11,639
  • 16
  • 61
  • 90