0

I have a cronjob setup using crontab that looks like this...

MAILTO=myemail@example.com
00 02 * * * /home/myaccount/myscript.sh

This works great and at 2AM it runs the script and emails me the output to myemail@example.com

The only issue is that the email subject and the name of the sender aren't very useful.

Is there a way to change them in the same way i can set the recipient email address?

Can I suppress the automatic email and pipe the output to mail myself?

3

Cron doesn't allow for a lot of configuration, but you can do this, assuming you have the mailutils package installed:

00 02 * * * /home/myaccount/myscript.sh 2>&1 | mail -s "My subject" $MAILTO

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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