0

Scenario 1:

     MAILTO=xyz@example.com
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 .

Private
  • 287

1 Answers1

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
ar_
  • 136
  • Thanks Can you pls explain | /usr/bin/tee -a /home/itadmin/.curator/logs.txt ? What does /usr/bin/tee path mean? – Private May 10 '17 at 12:34
  • tee is a program that reads stdout and writes its content into specified location. -a stands for append, which means that logs.txt will not be overwritten. – ar_ May 10 '17 at 12:38
  • Thanks.Whether the path is correct /usr/bin/tee or i have to keep /usr/local/bin/tee? – Private May 10 '17 at 12:41
  • It depends on your environment. Try using which tee to retrieve correct path. – ar_ May 10 '17 at 12:51