Oussema Benlagha
Oussema Benlagha

Reputation: 51

Why I'm getting unexpected EOF while looking for matching `'' for my cron job?

/bin/sh: -c: line 0: unexpected EOF while looking for matching `''
/bin/sh: -c: line 1: syntax error: unexpected end of file

Here's my Cron job:

*/1 * * * * aide --check | echo  "Start timestamp: `date +'%Y-%m-%d %H:%M:%S'`" > /var/log/aide/aide2.log

Upvotes: 0

Views: 1747

Answers (1)

user2021201
user2021201

Reputation: 380

This is because the % sign is treated specially in crontab. Those, if needed literally have to be escaped with \ Here is a quote from manpage:

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 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. There is no way to split a single command line onto multiple lines, like the shell's trailing "\".

However, as wRAR pointed, that pipe makes no sense. You probably wanted || there instead of |.

Upvotes: 1

Related Questions