Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I'm trying to send cron output to an email address and am struggling... I'm running the following command:

13 15 * * 1-5 root /path/to/ 2>&1 | mail -s "Daily Database Backup Report"

That shows this error within /var/mail/root

/usr/bin/mail: line 1: syntax error near unexpected token `('
/usr/bin/mail: line 1: `Config file not found (-s)'

Is this trying to validate/execute the output of the cron?

Do you do this on your server? If so, how?

share|improve this question

migrated from Jan 6 '12 at 14:50

This question came from our site for professional and enthusiast programmers.

3 Answers 3

up vote 1 down vote accepted

In my experience, /usr/bin/mail is a binary executable, but on your system the shell seems to be loading and interpreting it. syntax error near unexpected token is a bash diagnostic.

This can happen if you have overwritten an executable. Is there any conceivable chance that you have overwritten /usr/bin/mail with the text "Config file not found (-s)", causing said text to be fed to the shell when you try to execute it?

share|improve this answer

Have you tried mailx if it works? or check if you can do the mail within the bash script itself.

share|improve this answer

I suppose the outcome of your script ´/path/to/´ is binary, and the reason why mail runs into the error is because you cannot simply pipe binary output without encoding it.

A good way to attach files on command line is mutt. Check out the discussion at how-do-i-send-a-file-as-an-email-attachment-using-linux-command-line.

share|improve this answer

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.