[linux] Re: cron probleem (unexpected EOF)

Paul Slootman paul+nospam op wurtel.net
Wo Apr 2 14:34:35 CEST 2008


On Wed 02 Apr 2008, Peter Vollebregt wrote:

> hetzelfde commando als cron probeer uit te voeren gaat het mis:
> 
> /bin/echo "`(date +%Y-%m-%d\|%H:%M)`|`/usr/sbin/smartctl -d ata -a 
> /dev/sda| grep ^193 |awk '{ print $10}'`" >> /home/pvollebr/Load_Cycle_Count
> 
> Output:
> 2008-04-02|12:42|0
> 
> 
> En in cron:
> */5 * * * * /bin/echo "`(date +%Y-%m-%d\|%H:%M)`|`/usr/sbin/smartctl -d 
> ata -a /dev/sda| grep ^193 |awk '{ print $10}'`" >> 
> /home/pvollebr/Load_Cycle_Count
> 
> geeft dit de volgende fout in de mail:
> 
> /bin/sh: -c: line 0: unexpected EOF while looking for matching ``'

Een typisch gevalletje special feature die een hoop mensen niet kennen...:

       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 charac-
       ters, 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 "\".

Je moet dus % tekens escapen.


Paul Slootman



More information about the Linux mailing list