0

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" [email protected]

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?

3 Answers 3

1

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?

0

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

0

I suppose the outcome of your script ´/path/to/mysql-backup.sh´ 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.

You must log in to answer this question.

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