• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 413
  • Last Modified:

cron command substitution

Any ideas why the following line in cron doesn perform as expected

59 23 * * * /path/to/script.sh>>`/usr/bin/date '+%Y-%m-%d'`.log


It runs the script just fine but it does not creat the log file

0
jculkincys
Asked:
jculkincys
  • 2
1 Solution
 
jculkincysAuthor Commented:
the output it mailed to me

Your "cron" job on machinename
/path/to/script.sh>>`/usr/bin/date '+

produced the following output:

OUTPUT THAT I WANT TO GO TO THE .log file
0
 
ozoCommented:
try
59 23 * * * /path/to/script.sh>>`/usr/bin/date '+\%Y-\%m-\%d'`.log
0
 
yuzhCommented:
The reason is that "%" means the end of line in crontab.

The workaround is to use ESC char \ as suggest in http:#16702207 or put
the commands in a script, and run  the script as a corn job.
0
 
jculkincysAuthor Commented:
hmm
59 23 * * * /path/to/script.sh>>`/usr/bin/date '+\%Y-\%m-\%d'`.log
that worked a little bit

it created a file with the name "\2006-\05-\17.log"

Do I need spaces before and after the ">>" ?
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now