0

I have a strange problem. I use the following command line to send an eMail with attachment via console:

/usr/bin/mutt -s "AwStats $(date +%d.%m.%Y)" -a /path/to/file [email protected] < /dev/null

Works like a charm.

But I want it sent via cron, so I created this cronjob:

@daily root /usr/bin/mutt -s "AwStats $(date +%d.%m.%Y)" -a /path/to/file [email protected] < /dev/null 

The cronjob does get executed, but fails with this error message:

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

I have no idea why. Would anyone be able to help? Thank you VERY much in advance!

Kind regards -A

2 Answers 2

5

in crontab you need to escape %'s with a \ so

@daily root /usr/bin/mutt -s "AwStats $(date +\%d.\%m.\%Y)" -a /path/to/file [email protected] < /dev/null

will probably fix the problem for you.

2
  • Great, lain! Works like a charm now - Thank you very, very much for your help!!
    – Alex
    Apr 16, 2012 at 13:22
  • mark this solution as the correct on. hit the check mark Dec 18, 2014 at 0:36
2

In addition to Iain's answer, since cron is not bash you will probably also need to change

$(date +\%d.\%m.\%Y)

to be

`date +\%d.\%m.\%Y`

Or you could put all of your original job in a bash script and just call the script instead.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .