In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
CentOS 7.7.How to use the Shell script to monitor the number of logged-in users and configure QQ Mail to send email alarms. In view of this question, this article introduces in detail the corresponding analysis and answers, hoping to help more partners who want to solve this problem to find a more simple and easy way.
First, configure QQ Mail to send mail:
# yum-y install mailx
# cp / etc/mail.rc {, .bak}
# vim / etc/mail.rc, with the following code added at the end:
Set from=834143808@qq.com
Set smtp=smtp.qq.com
Set smtp-auth-user=834143808@qq.com
Set smtp-auth-password=QQ mailbox authorization code
Set smtp-auth=login
# echo "Hello World" | mail-s "test" 834143808@qq.com
Second, write a Shell script to monitor the number of logged-in users:
Goal: the number of logged-in users in the system is more than 3, and email alarm is realized.
# mkdir-pv / scripts
# vim / scripts/check_users.sh
#! / bin/bash
Users= `who | wc-l`
If [$users-gt 3]; then
Echo "the number of current system login users is $users" | mail-s "system login users" 834143808@qq.com
Fi
# chmod + x / scripts/check_users.sh
III. Prepare a mission plan:
# crontab-e
* / 5 * / scripts/check_users.sh & > / dev/null
Fourth, open more connection windows, simulate multi-user login, and test email alarms:
This is the answer to the question about how CentOS 7.7 uses the Shell script to monitor the number of logged-in users and configure QQ Mail to send email alarms. I hope the above content can be of some help to all of you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.