Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 < /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 < /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

share|improve this question

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 < /dev/null

will probably fix the problem for you.

share|improve this answer
Great, lain! Works like a charm now - Thank you very, very much for your help!! – Alex Apr 16 '12 at 13:22
mark this solution as the correct on. hit the check mark – Felipe Alvarez Dec 18 '14 at 0:36

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.

share|improve this answer
Thank you very much, Ladadadada! – Alex Apr 16 '12 at 13:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.