<< All Posts
How to send an email when execute a crontab task


Would like to send an email when your crontab task has executed?

Let’s edit your crontab just typing:

crontab -e

In your first line just put these parameters. Remember if you are using VI, you have to use “ESC + i” to activate insert mode:

MAILTO="your_email_here@your_server.com"
59 10 * * * echo test

These commands will execute on 10:59am and is gonna print just test on background shell. Just for test our email. Of course that you have to be your sendmail activated on your server.

To save using VI, just type: “ESC + x”

To check if this commands are saved just type:

crontab -l

That’s it!

 



<< All Posts

rodolfo.io

🇧🇷 🇨🇦
Runs on OpenBSD 🐡