定时发送邮件
部署邮件服务
查看有没有安装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