否则我每天收到一封关于cron输出的电子邮件,我很难看到错误发生的时间.
解决方法 怎么样59 23 * * * { tmpfile=/tmp/yourCmdErrs.$$; export tmpfile ; yourCommand > /dev/null 2>${tmpfile}; if [ -s ${tmpfile} ] ; then mailx -s"errors in yourCommand" < ${tmpfile} ; /bin/rm ${tmpfile} ; fi ; }
爆炸,它是
# set whatevery your time/days are # 59 23 * * * # my superstition to use open and closing # { }# set a tmpfile var # tmpfile=/tmp/yourCmdErrs.$$; export tmpfile ;# run yourCmd save STDERR to file # yourCommand > /dev/null 2>${tmpfile}; # check if tmpfile has anything in it # if [ -s ${tmpfile} ] ; then # obvIoUs,hopefully # mailx -s"errors in yourCommand" < ${tmpfile} # cleanup tmpfile # /bin/rm ${tmpfile} ;# fi # note that closing ';' is a must when using {} pairs ; }
对mail / mailx的实际调用可能有点时髦,我现在没办法测试它.
我希望这有帮助.
总结以上是内存溢出为你收集整理的linux – 如何将cron输出发送到null并将错误发送到电子邮件?全部内容,希望文章能够帮你解决linux – 如何将cron输出发送到null并将错误发送到电子邮件?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)