Follow the bird's "private cuisine" to learn the routine work of Linux this chapter, need to configure the/etc/crontab file for automated scheduling, the experimental process if a work execution results have output or error when the default will send a message to the root administrator. At that time, it was considered that if the 163 or other mailboxes that were used directly could be more convenient to solve the problem, the next step was to solve the problem.
From the Internet to find a lot of information, most of the need to configure the SMTP server or need to install sendmail what software to solve the problem of outgoing mail, which has a relatively practical (contact is not much, perhaps for me at present more practical), do not need to install third-party programs, direct configuration/etc/ Mail.rc This file SMTP configuration for NetEase smtp.163.com, followed by the relevant configuration:
vim/etc/mail.rc# Add set from= "here to fill in your email address" smtp=smtp.163.comset smtp-auth-user= "email username" smtp-auth-password= "email password" SM Tp-auth=login
configuration complete crontab configuration
shell=/bin/bashpath=/sbin:/bin:/usr/sbin:/usr/bin[email protected] #测试邮箱替换为自己的邮箱即可 #MAILTO =roothome=/# for details see man 4 crontabs# example of job definition:# .---------------- minute (0 - 59) # | .--------- ---- hour (0 - 23) # | | .---------- day of month (1 - 31) # | | | .------- month (1 - ( OR JAN,FEB,MAR,APR ...# |  |  |  | &NBSP):---- day of week (0 - 6) (sunday=0 or 7) or sun,mon,tue,wed , thu,fri,sat# | | | | |# * * * * * user-name command to be executed */2 * * * * root run-parts /root/runcron >> /root/cron/log/crontab.log
In the chapter that explains the script, there is a script that automatically pings the network status of a network segment, this time bring him to the root. Create a new Runcron folder, which is used to execute the shell script from the crontab call at some point in time. Run-parts is the function of this command is to talk about all the files in the next directory to find out to execute, if only need to execute a script or command, the run-parts is replaced with the corresponding script name, and the following folder is also removed. Because this test only sends the message when the error occurs, the output of the program execution is redirected to the/root/cron/log/crontab.log file.
The following is the effect after the execution, in the test deliberately write the log folder incorrectly so that the output can not be written to Crontab.log and error messages sent to the e-mail message in the form to fill in the mailbox.
650) this.width=650; "src=" http://s2.51cto.com/wyfs02/M02/80/0E/wKiom1c1inWghelEAABnxkr19OM411.jpg "title=" 1.jpg " alt= "Wkiom1c1inwgheleaabnxkr19om411.jpg"/>
650) this.width=650; "src=" http://s2.51cto.com/wyfs02/M02/80/0B/wKioL1c1i1jjRGe5AABTb_Ackks982.jpg "style=" float: none; "title=" 2.jpg "alt=" Wkiol1c1i1jjrge5aabtb_ackks982.jpg "/>
650) this.width=650; "src=" http://s2.51cto.com/wyfs02/M00/80/0E/wKiom1c1inbz_btuAAEP8u6ZU_A147.jpg "style=" float: none; "title=" 3.jpg "alt=" Wkiom1c1inbz_btuaaep8u6zu_a147.jpg "/>
This article from "Product small stream, into Jianghai" blog, please be sure to keep this source http://goodjoe.blog.51cto.com/9173556/1773071
CentOS Routine work forwarding external mailbox