当前位置: 首页 > news >正文

实现定时发送邮件,以及时间同步

定时发送邮件

部署邮件服务

查看有没有安装mailx,安装了

[root@192 ~]# rpm -q mailx
mailx-12.5-43.fc38.x86_64

去网易拿一下授权码,写到配置文件里

vim /etc/mail.rcset from=xxxxxxx@163.com
set smtp=smtp.163.com
set smtp-auth-user=xxxxxxx@163.com
set smtp-auth-password=XXXXXXXXXXX
set smtp-auth=login

测试邮件发送

[root@192 ~]# echo 11111 | mail -s test xxxxxxxxxxx@163.com

在这里插入图片描述

每天9点定时给自己发送邮件提醒自己,I’m the best.

检查是否安装crond

[root@192 ~]# rpm -q crontabs
crontabs-1.11-27.20190603git.el9_0.noarch
crontab -e
MATLTO=xxxxx@163.com0 9 * * * echo "im best" | mail -v -s "test" xxxxxx@163.com

通过两台linux主机模拟实现linux主机时间同步操作

主机配置

[root@192 ~]# rpm -q chrony
chrony-4.5-3.el9.x86_64

打开配置文件

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (https://www.pool.ntp.org/join.html).
#pool 2.rhel.pool.ntp.org iburst //本机为时间服务器,注释掉# Use NTP servers from DHCP.
sourcedir /run/chrony-dhcp# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift# Allow the system clock to be stepped in the first three updates
# if its offset is larger than 1 second.
makestep 1.0 3# Enable kernel synchronization of the real-time clock (RTC).
rtcsync# Enable hardware timestamping on all interfaces that support it.
#hwtimestamp *# Increase the minimum number of selectable sources required to adjust
# the system clock.
#minsources 2# Allow NTP client access from local network.
allow 192.168.214.0/24 //允许谁访问# Serve time even if not synchronized to a time source.
local stratum 10 //层级10# Require authentication (nts or key option) for all NTP sources.
#authselectmode require# Specify file containing keys for NTP authentication.
keyfile /etc/chrony.keys# Save NTS keys and cookies.
ntsdumpdir /var/lib/chrony# Insert/delete leap seconds by slewing instead of stepping.
#leapsecmode slew# Get TAI-UTC offset and leap seconds from the system tz database.
leapsectz right/UTC# Specify directory for log files.

客户端配置

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (https://www.pool.ntp.org/join.html).
#pool 2.centos.pool.ntp.org iburst
pool 192.168.214.130 iburst //另一个主机为服务器
# Use NTP servers from DHCP.
sourcedir /run/chrony-dhcp# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift# Allow the system clock to be stepped in the first three updates
# if its offset is larger than 1 second.
makestep 1.0 3# Enable kernel synchronization of the real-time clock (RTC).
rtcsync# Enable hardware timestamping on all interfaces that support it.
#hwtimestamp *# Increase the minimum number of selectable sources required to adjust
# the system clock.
#minsources 2# Allow NTP client access from local network.
#allow 192.168.0.0/16# Serve time even if not synchronized to a time source.
#local stratum 10# Require authentication (nts or key option) for all NTP sources.
#authselectmode require# Specify file containing keys for NTP authentication.
keyfile /etc/chrony.keys# Save NTS keys and cookies.
ntsdumpdir /var/lib/chrony

修改时间

在这里插入图片描述

同步时间

在这里插入图片描述

相关文章:

  • 【Unity】UI点击事件处理器
  • CS144 Lab0实战记录:搭建网络编程基础
  • 【Leetcode 每日一题 - 补卡】1534. 统计好三元组
  • HBuilder安装PHP开发插件教程
  • 浔川AI翻译v7.0更新预告
  • 深度解析Spring @Scheduled:从基础使用到高级定制
  • Java反射知识点学习笔记
  • VS Code 安装及常用插件
  • 【计算机视觉】OpenCV实战项目-AdvancedLaneDetection 车道检测
  • NLP高频面试题(四十六)——Transformer 架构中的位置编码及其演化详解
  • RPCRT4!OSF_CCALL::ActivateCall函数分析之RPCRT4!OSF_CCALL结构中的Bindings--RPC源代码分析
  • 2025中国移动云智算大会回顾:云智变革,AI+跃迁
  • PHP开发环境搭建(Hbuider+phpstudy)
  • 数据通信学习笔记之OSPF配置命令
  • 知识图谱中医知识问答系统|养生医案综合可视化系|推荐算法|vue+flask+neo4j+mysql
  • MATLAB 程序实现了一个层次化光网络的数据传输模拟系统
  • 【Linux基础】sqlite数据库
  • 观察者模式与发布订阅模式:解耦与通信的艺术
  • SpringBoot 动态加载 Jar 包
  • 【c语言】深入理解指针2
  • 体坛联播|欧冠巴萨3比3战平国米,柯洁未进入国家集训队
  • 马上评|什么才是地方文旅宣传的正确姿势
  • 建行一季度净利833.51亿同比下降3.99%,营收降5.4%
  • 保利发展去年净利润约50亿元,在手现金1342亿元
  • 葡萄牙总理:未来几小时内将全面恢复供电
  • 四川省社科联期刊:不建议在读硕士、博士将导师挂名为第一作者