linux - How to send email and store log file from a single cronjob? -


i have cronjob:

* * * * * root  echo 'blabla' 

it easy 1 :)

now, send email when cronjob done, store log in log file.

i tryed this:

* * * * * root  echo 'blabla'  | mail -s "cron report" test@example.com  > /test/test.log 2>&1 

the email sent , test.log file created, test.log file empty.

any idea why?

this because redirecting output of echo mail there nothing write log file. result, log file empty.

if want write output of echo log file , send mail, use tee shown below:

echo 'blabla'  2>&1 | tee /test/test.log | mail -s "cron report" test@example.com 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -