PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : cron: unexpected EOF while looking for matching ``'



heuki
26.06.07, 07:30
Hallo zusammen,

habe ein komisches Problem mit cron und da ich überhaupt nicht weiterkomme, wende ich mich mal an Euch.

In einer Datei unterhalb von cron.d habe ich (unter anderem) die Zeile:


34 4 * * * root /usr/bin/mysqldump -A -a | bzip2 > /root/backups/mysqldump.`/bin/date +%Y-%m-%d`.bz2

Jedesmal wenn der Befehl ausgeführt werden soll, bekomme ich per Email:

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

Wenn ich die Zeile aber aus der Datei kopiere und direkt in die bash paste, dann wird der Befehl ausgeführt wie er sollte.

Danke für Eure Hilfe,
Stefan

MiGo
26.06.07, 07:56
In einer Datei unterhalb von cron.d habe ich (unter anderem) die Zeile:
Sicher, dass das aus der Datei kommt und nicht aus einer anderen?

Ansonsten könntest du es auch mal mit
34 4 * * * root /usr/bin/mysqldump -A -a | bzip2 > /root/backups/mysqldump.$(/bin/date +%Y-%m-%d).bz2
versuchen.

heuki
26.06.07, 18:03
Danke für Deine Antwort. Das ist wirklich sehr komisch. Mit den Klammern, wie Du es vorgeschlagen hast, funktioniert es auch nicht (gleicher Fehler nur mit fehlender schließender Klammer). Da ist mir aufgefallen, dass in den Betreffzeilen der Emails nur der Befehl bis zum "+" steht. Ersetze ich jetzt das +%Y-%m-%d gegen +abc, dann funktioniert es ganz wunderbar - sowohl mit Klammern als auch mit backticks. Es scheint also, als mag cron die Prozentzeichen nicht.

Ich habe es gerade mal ausprobiert und % ist kein Kommentarzeichen in diesem Skript.

MiGo
27.06.07, 18:19
Ist ein Zeilenumbruch in den Script nach dem Befehl?

L00NIX
07.07.07, 11:14
Das Problem sind die %-Zeichen, die innerhalb der crontab Sonderzeichen sind. Lies mal die manpage zu crontab(5):


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 "\".

[...]

# run at 10 pm on weekdays, annoy Joe
0 22 * * 1-5 mail -s "It’s 10pm" joe%Joe,%%Where are your kids?%

[...]


Gruß
L00NIx