Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 myemail@gmail.com < /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 myemail@gmail.com < /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

2 Answers 2

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 myemail@gmail.com < /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.