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

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

定时发送邮件

部署邮件服务

查看有没有安装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

修改时间

在这里插入图片描述

同步时间

在这里插入图片描述

http://www.xdnf.cn/news/60.html

相关文章:

  • 【口腔粘膜鳞状细胞癌】文献阅读3
  • 《前端性能优化秘籍:打造极致用户体验》
  • Windows 图形显示驱动开发-WDDM 1.2功能—Windows 8 中的 DirectX 功能改进(四)
  • Linux之 grep、find、ls、wc 命令
  • Sentinel源码—4.FlowSlot实现流控的原理二
  • 【NLP 64、基于LLM的垂直领域【特定领域】问答方案】
  • kotlin + spirngboot3 + spring security6 配置登录与JWT
  • 【安卓开发】【Android Studio】Menu(菜单栏)的使用及常见问题
  • 【HDFS入门】HDFS与Hadoop生态的深度集成:与YARN、MapReduce和Hive的协同工作原理
  • 观察者设计模式详解:解耦通知机制的利器
  • 16-算法打卡-哈希表-两个数组的交集-leetcode(349)-第十六天
  • Flutter 常用命令
  • Qt GUI 库总结
  • gitee新的仓库,Vscode创建新的分支详细步骤
  • Python 实现日志备份守护进程
  • MCP理解笔记及deepseek使用MCP案例介绍
  • 每日算法-链表(23.合并k个升序链表、25.k个一组翻转链表)
  • Java 开发玩转 MCP:从 Claude 自动化到 Spring AI Alibaba 生态整合
  • pycharm无法识别到本地python的conda环境解决方法
  • 【远程管理绿联NAS】家庭云存储无公网IP解决方案:绿联NAS安装内网穿透
  • 数字孪生城市技术应用典型实践案例汇编(22个典型案例)(附下载)
  • 20.3 使用技巧3
  • Openfein实现远程调用的方法(实操)
  • 【音视频开发】第五章 FFmpeg基础
  • 最新Spring Security实战教程(十一)CSRF攻防实战 - 从原理到防护的最佳实践
  • 逻辑回归 (Logistic Regression)
  • 山东大学软件学院创新项目实训开发日志(18)之对话自动生成标题设为用户第一次对话发的文字
  • 第五章 SQLite数据库:3、SQLite 常用语法及使用案例
  • requestAnimationFrame 深度理解
  • AI在多Agent协同领域的核心概念、技术方法、应用场景及挑战 的详细解析