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

LVL 2
jculkincysAsked:
Who is Participating?
 
ozoCommented:
try
59 23 * * * /path/to/script.sh>>`/usr/bin/date '+\%Y-\%m-\%d'`.log
0
 
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
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.