Using MAILTO in cronjob?

Scenario 1:

     [email protected]
10 12 * * * /usr/local/bin/curator --dry-run --config /home/itadmin/.curator/curator.yml /home/itadmin/.curator/snapshotdaily.yml >> /home/itadmin/.curator/logs.txt 2>&1

By this all the STDOUT and STDERR are going to logs.txt.

Scenario 2 :

If i am using like this :

 10 12 * * * /usr/local/bin/curator --config /home/itadmin/.curator/curator.yml /home/itadmin/.curator/snapshotdaily.yml 

I am getting mail but not getting stored in logs.txt

What i want is the combination of both 1 and 2: I want my every day logs appeneded to be in logs.txt file for history purpose and also want daily logs to be sent in mail .


Solution 1:

Try tee:

10 12 * * * /usr/local/bin/curator --dry-run --config /home/itadmin/.curator/curator.yml /home/itadmin/.curator/snapshotdaily.yml 2>&1 | /usr/bin/tee -a /home/itadmin/.curator/logs.txt