Cronjob to add datestamp to file not running

Viewed 34

Good day everyone.

I have an issue, and Googling the issue has not helped me, basically I have the following requirement.

  1. cronjob that runs 1st script, output is written to a file
  2. file that is created, to have a date stamp
  3. 2nd script executes, mail the generated file as an attachment

The issue is with adding the timestamp, if I set the cron to run and just create a file with a generic filename the cronjob runs fine.

I have tried the following:

0 8-17/1 * * * python /usr/local/bin/script1.py >> /usr/local/bin/file_`date +\%Y-%m-%d`.txt 2>&1 && python /usr/local/bin/email_script.py

0 8-17/1 * * * python /usr/local/bin/acme_transcoding_check.py >> /usr/local/bin/file_$(date +"%Y-%m-%d").txt 2>&1 && python /usr/local/bin/email_script.py

Server is running Ubuntu 16.04

1 Answers

You need to escape the percent-sign (%) with a backslash as explained in this answer (not mine).

Related