bash OK, Cron job not?

John Horne john.horne at plymouth.ac.uk
Mon Aug 20 16:46:21 UTC 2007


On Mon, 2007-08-20 at 12:42 -0400, Mark Haney wrote:
> I have a strange problem I can't seem to figure out.  Maybe it's the
> newbie in me. Below I have the following running in a cron job:
> 
> mail -s "LDM missing files totals: LDM1 `date +%D`" ....
> 
> Now, from bash this works perfectly, I get the date and everything.  But
> from cron I get this:
> 
> > /bin/sh: -c: line 0: unexpected EOF while looking for matching ``'
> > /bin/sh: -c: line 1: syntax error: unexpected end of file
> 
> Can someone explain to me why?
> 
Put a backslash (\) before the percent sign in your cron job. It needs
escaping; this has caught me out several times :-)

So, try:

   mail -s "LDM missing files totals: LDM1 `date +\%D`"



John.

-- 
---------------------------------------------------------------
John Horne, University of Plymouth, UK  Tel: +44 (0)1752 233914
E-mail: John.Horne at plymouth.ac.uk       Fax: +44 (0)1752 233839




More information about the fedora-list mailing list