定時發送郵件
部署郵件服務
查看有沒有安裝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