Take the 2-minute tour ×
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/mysql-backup.sh 2>&1 | mail -s "Daily Database Backup Report" my.email@emailhost.com

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 stackoverflow.com Jan 6 '12 at 14:50

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

3 Answers 3

up vote 0 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

This is working fine for me.

0 3 * * * /opt/appsomething/scripts/mysqlbkp_localserver.sh 2>&1 mail -s "Backup routine from server" root
share|improve this answer
1  
Not sure how this helps the OP. For one they've already marked an accepted A, and for another you're showing essentially the same thing that wasn't working for them. Perhaps if you expanded your A a bit that might help shed light on what's different with your working example vs. their not working example. –  slm Jul 3 at 20:26

Your Answer

 
discard

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.