Mail linux status lufy December 09, 2017 <p>When we are doing some tests on linux that take very long time, and we have to monitor its status at every moment, in this case, we can set the mail client on linux, to inform test status through email. Next is how to set.</p> <p>1. Edit <span style="font-family: 'courier new', courier;">/etc/mail.rc</span></p> <p># add the followed lines</p> <p><span style="font-family: 'courier new', courier;">set from=fei.lu@i-soft.com.cn smtp=mail.lufy90.com</span><br /><span style="font-family: 'courier new', courier;">set smtp-auth-user=lufy@lufy90.com smtp-auth-password=passwd smtp-auth=login</span></p> <p>Then you can test your mail set with command:</p> <p><span style="font-family: 'courier new', courier;">]# ps -ef | mail -s test test@lufy90.com</span></p> <p>The email titled with test from lufy@lufy90.com should be received.</p> <p>2. edit <span style="font-family: 'courier new', courier;">/etc/crontab</span></p> <p><span style="font-family: 'courier new', courier;">/etc/crontab</span> is used for setting scheduled jobs on linux. Daemon cron would execute jobs(commands) set in <span style="font-family: 'courier new', courier;">/etc/crontab</span>. Here we can join the mail commands to schedule, such as push the output of test-info every hour:</p> <p><span style="font-family: 'courier new', courier;">]# vim /etc/crontab</span></p> <p><span style="font-family: 'courier new', courier;">0 * * * * root test-info | mail -s “Test status” test@lufy90.com</span></p> <p> </p> <p>About crontab:</p> <p><span style="font-family: 'courier new', courier;">*/5 * * * * # every 5min</span></p> <p><span style="font-family: 'courier new', courier;">0 * * * * # every hour</span></p> <p><span style="font-family: 'courier new', courier;">0 0 * * * # every day</span></p> <p><span style="font-family: 'courier new', courier;">0 0 * * 0 # every week</span></p> <p><span style="font-family: 'courier new', courier;">0 0 1 * * # every month</span></p> <p><span style="font-family: 'courier new', courier;">0 0 1 1 * # every year</span></p>
Comments (0)
Leave a Comment
No comments yet. Be the first to comment!