Crontab can run programs regularly, but sometimes there are problems with the program, and to monitor the program we can view the log of crontab, but unfortunately Linux (Ubuntu) turns off the log of crontab by default, so it's OK to turn on log. strong> Modify Rsyslog
<code class= "Language-shell hljs Haskell has-numbering" style=; padding:0px; Color:inherit; Box-sizing:border-box; font-family: ' Source Code Pro ', monospace;font-size:undefined; White-space:pre; border-radius:0px; Word-wrap:normal; background:transparent; " ><span class= "Hljs-title" style= "Box-sizing:border-box;" >sudo</span> vim/etc/rsyslog.d/<span class= "Hljs-number" style= "Color:rgb (0, 102, 102); Box-sizing:border-box; " >50</span>-<span class= "Hljs-default" style= "Box-sizing:border-box;" ><span class= "Hljs-keyword" style= "Color:rgb" (0, 0, 136); Box-sizing:border-box; " >default</span>.conf</span></code><ul class= "pre-numbering" style= "Box-sizing:border-box ; Position:absolute; width:50px; top:0px; left:0px; margin:0px; padding:6px 0px 40px; border-right-width:1px; Border-right-style:solid; Border-right-color:rgb (221, 221, 221); List-style:none; Text-align:right; Background-color:rgb (238,238, 238); " ><li style= "Box-sizing:border-box; padding:0px 5px; " >1</li></ul>
Vim in
cron.*/var/log/cron.log #将cron前面的注释符去掉 Restart rsyslog
<code class= "Language-shell hljs bash has-numbering" style= "display:block; padding:0px; Color:inherit; Box-sizing:border-box; font-family: ' Source Code Pro ', monospace;font-size:undefined; White-space:pre; border-radius:0px; Word-wrap:normal; background:transparent; " ><span class= "hljs-built_in" style= "Color:rgb" (102, 0, 102); Box-sizing:border-box; " >sudo</span> service Rsyslog restart</code><ul class= "pre-numbering" style= "Box-sizing:border-box" ; Position:absolute; width:50px; top:0px; left:0px; margin:0px; padding:6px 0px 40px; border-right-width:1px; Border-right-style:solid; Border-right-color:rgb (221, 221, 221); List-style:none; Text-align:right; Background-color:rgb (238, 238, 238); ><li style= "Box-sizing:border-box; padding:0px 5px; " >1</li></ul>
View crontab Log
<code class= "Language-shell hljs lasso has-numbering" style=; padding:0px; Color:inherit; Box-sizing:border-box; font-family: ' Source Code Pro ', monospace;font-size:undefined; White-space:pre; border-radius:0px; Word-wrap:normal; background:transparent; " >less/<span class= "hljs-built_in" style= "Color:rgb" (102, 0, 102); Box-sizing:border-box; " >var</span>/<span class= "Hljs-keyword" style= "Color:rgb" (0, 0, 136); Box-sizing:border-box; " >log</span>/cron<span class= "hljs-built_in" style= "Color:rgb" (102, 0, 102); Box-sizing:border-box; " >.</span><span class= "Hljs-keyword" style= "Color:rgb" (0, 0, 136); Box-sizing:border-box; " >log</span> </code>