Cron job stderr to email AND log file?

前端 未结 9 1702
离开以前
离开以前 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:34

    Not sure why nobody mentioned this.

    With CRON if you specify MAILTO= in the users crontab, STDOUT is already sent via mail.

    Example

    [temp]$ sudo crontab -u user1 -l
    SHELL=/bin/bash
    PATH=/sbin:/bin:/usr/sbin:/usr/bin
    MAILTO=user1
    # transfer order shipping file every 3 minutes past the quarter hour
    3,19,33,48 * * * * /home/user1/.bin/trans.sh
    

提交回复
热议问题