Centos7 regularly sends the linux system status by email

Source: Internet
Author: User
# Vim/etc/mail. rc adds the following two lines at the end of the document: setfrom = *** @ 163. comsmtp = smtp.163.comsetsmtp-auth-user = *** @ 163. comsmtp-auth-password = *** smtp-auth = a line of command below login to test whether an email can be sent to *** @ qq.com # cat

# Vim/etc/mail. rc

Add the following lines at the end of the document:

Set from = *** @ 163.com smtp = smtp.163.com

Set smtp-auth-user = *** @ 163.com smtp-auth-password = *** smtp-auth = login

The following line tests whether an email can be sent to *** @ qq.com

# Cat/etc/passwd | mail-s "system statue" 173056183@qq.cm

# Vim/root/space. sh

Mail-s "system status" 275807981@qq.com <EOF

'Echo "----------- mysql data space use -----------"

Du-h/mydata

Echo "----------- home data space use -----------"

Du-h/home-d 1

Echo "----------- cpu load -----------"

Uptime

Echo "---------- who is login ----------"

Who

Echo "---------- mem swap -----------"

Free-H'

EOF

Prepare and execute tasks

# Vim/etc/crontab

Add the following line at the end of the document and execute it once a day

0 1 *** root sh/root/spaceuse. sh

The effect is as follows:

Related Article

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.