[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: What's wrong with this entry in a cron job?



Hello,

On 2024-03-30 10:52, Freek de Kruijf wrote:
I have the following line in a cron job:

1 1 * * * rm -v /srv/db/webhoneypot-$(date --date=yesterday +%Y-%m-%d).json

I get in the journal:

Mar 30 01:01:01 rpi4rasphon CRON[1254]: (root) CMD (rm -v /srv/db/webhoneypot-
$(date --date=yesterday +)

and in the e-mail

/bin/sh: 1: Syntax error: end of file unexpected (expecting ")")

man 5 crontab says:
[..]
The ``sixth'' field (the rest of the line) specifies the command to be run. 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 cronfile. Percent-signs (%) in the command, un‐ less escaped with backslash (\), will be changed into newline charac‐ ters, and all data after the first % will be sent to the command as
       standard input.

Regards,

Leigh.


Reply to: