linux-no.03 Linux Set Timer task Send mail function

Source: Internet
Author: User

1. Scheduled Tasks

CRONTAB-LCRONTAB-E/sbin/service crond Start//start service/sbin/service Crond stop//shutdown service/sbin/service crond Restart//  Restart Service/sbin/service Crond Reload//Reload configuration/sbin/service crond Status//view service Status */1 * * * */opt/shell/load-check.sh00 03 * * */opt/shell/download_log.sh* */1 * * */opt/shell/diskfree.shps-ax | grep cron

2. Send mail

#!/bin/bashpercent= ' df -k | grep -v filesystem| awk  ' {print int} ' for each_one in  $percentdo         if [  $each _ one -ge 90 ];then                 echo  $each _one                 email_date=$ (date  "+%y-%m-%d %h:%m:%s")                  echo  "email_date : " $email _date  >> /opt/disk.log                 echo  "server : 120.132.38.102"  >> /opt/disk.log                 df -h > > /opt/disk.log                from_name= " Shaohua "                from=" [Email protected] "                 r1= "[email protected]"                  to= "< $r 1>"                   #email_title = "120.132.38.102 disk critical"                  email_content= "/opt/disk.log"                 email_subject= "120.132.38.102 disk critical"                  echo -e  "to:  ${to}\nfrom: \" ${from_name}\ " <${from}>\nsubject: ${email_ subject}\n\n ' cat ${email_content} '  | /usr/sbin/sendmail -t                 rm -rf /opt/disk.log                 break         fidone

linux-no.03 Linux Set Timer task Send mail function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.