I have the code like this :
54 08 * * * /usr/local/bin/curator --dry-run --config /home/itadmin/.curator/curator.yml /home/itadmin/.curator/daily.yml 2>&1 | /usr/bin/tee -a /home/itadmin/.curator/logs.txt | /usr/bin/tee /home/itadmin/.curator/history.txt | if [ $(wc -l </home/itadmin/.curator/history.txt) -ge 2 ]; then mail -s 'Snapshot Status' xyz@abc.com; fi
What i am doing is i am sending the output of cron to logs.txt for history purpose and sending the same to history.txt in which the if condition will work.
Actually the cron output is like this
2017-05-17 08:33:01,395 INFO Preparing Action ID: 1, "snapshot"
2017-05-17 08:33:01,404 INFO Master-only flag detected. Connected to non-master node. Aborting.
But i got in logs.txt is
2017-05-17 08:54:01,427 INFO Preparing Action ID: 1, "snapshot"
IN history.txt file i got nothing
But these worked fine when i did the remove the if command(i.e.if [ $(wc -l </home/itadmin/.curator/history.txt) -ge 2 ]; then mail -s 'Snapshot Status' xyz@abc.com; fi)
.
I dont know why this is happening?
THANKS