0

Possible Duplicate:
How can I execute date inside of a cron tab job?

I made a cronjob to record a stream every friday between 23pm and midnight. Only somehow this doesn't seem to work.

the cronjob is

57 22 * * 5 timeout -s SIGINT 66m mplayer -dumpstream http://82.201.100.23:80/slamfm -dumpfile /var/www/HOA-NL/$(date +"%U-%Y").mp3 >> /home/david/HOA-NL-LOG 2>&1

This doesn't work while the following works

57 22 * * 5 echo "foo" > /home/david/barr

and the following works either (timing out echo doesn't make sense, I know. It's just an example)

57 22 * * 5 timeout -s SIGINT 66m echo "foo" > /home/david/barr

Now I'm wondering why this doesn't work.. It doesn't give me a error or a message in /home/david/HOA-NL-LOG

1 Answers1

8

You've committed the classic error of using date +%foo in a cron job, causing you to bump into cron's most baffling feature. Clearly documented in man 5 crontab but often overlooked, here it is:

The entire command portion of the line, up to a newline or % character, will be executed by /bin/sh or by the shell specified in the SHELL variable of the crontab file. Percent-signs (%) in the command, unless escaped with backslash (\), will be changed into newline characters, and all data after the first % will be sent to the command as standard input.

Backslash your percent signs!

Alan Curry
  • 2,274