Cron job stderr to email AND log file?

前端 未结 9 1676
离开以前
离开以前 2021-01-06 07:57

I have a cron job:

$SP_s/StartDailyS1.sh >$LP_s/MirrorLogS1.txt

Where SP_s is the path to the script and LP_s

9条回答
  •  南方客
    南方客 (楼主)
    2021-01-06 08:40

    I assume you are using bash, you redirect stdout and stderr like so

    1> LOG_FILE
    2> LOG_FILE
    

    to send a mail containing the stderr in the body something like this

    2> MESSAGE_FILE
    /bin/mail -s "SUBJECT" "EMAIL_ADDRESS" < MESSAGE_FILE
    

    I'm not sure if you can do the above in only one passage as this

    /bin/mail -s "SUBJECT" "EMAIL_ADDRESS" <2
    

提交回复
热议问题