A
A
avp2018-11-29 22:57:16
linux
avp, 2018-11-29 22:57:16

How to send only cron alerts?

A task has arisen. It is required that for all tasks in cron files. It was possible to send cron alerts to the mail. For example, if the script started with an error.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
vman, 2018-11-29
dnepr @avpdnepr

Just write
MAILTO="<mail address>" at the beginning of the cron file
and cron will send emails to the specified address. In this case, you need to make sure that a mail server, such as Postfix, is installed on the server.
such a task will send a message every time the script is executed (or not executed)

MAILTO="[email protected]"
* * * * * /bin/myjob.sh

and this option should send messages only if an error occurs with output to STDERR
MAILTO="[email protected]"
* * * * * /bin/myjob.sh > /dev/null

M
Mysterion, 2018-11-29
@Mysterion

[email protected]
* * * * * /root/script.sh > /dev/null

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question