Loading... # 概念 ## RTC Time RTC(Real Time Clock,实时时钟)也叫做 CMOS 时钟,它是 PC 主机板上的一块芯片(或者叫做时钟电路),它靠电池供电,即使系统断电也可以维持日期和时间。 # 操作 ```bash ┌[root@localhost] [/dev/pts/0] └[~]> timedatectl Local time: Tue 2023-04-25 16:48:08 CST Universal time: Tue 2023-04-25 08:48:08 UTC RTC time: Tue 2023-04-25 08:48:08 Time zone: Asia/Shanghai (CST, +0800) System clock synchronized: yes NTP service: active RTC in local TZ: no ``` 时区和时间的准确性 ## 修改时间 ```bash date -s "2023-04-25 16:00:00" ``` ## 修改时区 ```bash ┌[root@localhost] [/dev/pts/0] └[~]> tzselect Please identify a location so that time zone rules can be set correctly. Please select a continent, ocean, "coord", or "TZ". 1) Africa 2) Americas 3) Antarctica 4) Asia 5) Atlantic Ocean 6) Australia 7) Europe 8) Indian Ocean 9) Pacific Ocean 10) coord - I want to use geographical coordinates. 11) TZ - I want to specify the time zone using the Posix TZ format. #? 4 Please select a country whose clocks agree with yours. 1) Afghanistan 29) Kyrgyzstan 2) Antarctica 30) Laos 3) Armenia 31) Lebanon 4) Azerbaijan 32) Macau 5) Bahrain 33) Malaysia 6) Bangladesh 34) Mongolia 7) Bhutan 35) Myanmar (Burma) 8) Brunei 36) Nepal 9) Cambodia 37) Oman 10) China 38) Pakistan 11) Christmas Island 39) Palestine 12) Cocos (Keeling) Islands 40) Philippines 13) Cyprus 41) Qatar 14) East Timor 42) Russia 15) French Southern Territories 43) Réunion 16) Georgia 44) Saudi Arabia 17) Hong Kong 45) Seychelles 18) India 46) Singapore 19) Indonesia 47) Sri Lanka 20) Iran 48) Syria 21) Iraq 49) Taiwan 22) Israel 50) Tajikistan 23) Japan 51) Thailand 24) Jordan 52) Turkmenistan 25) Kazakhstan 53) United Arab Emirates 26) Korea (North) 54) Uzbekistan 27) Korea (South) 55) Vietnam 28) Kuwait 56) Yemen #? 10 Please select one of the following time zone regions. 1) Beijing Time 2) Xinjiang Time, Vostok #? 1 The following information has been given: China Beijing Time Therefore TZ='Asia/Shanghai' will be used. Selected time is now: Tue Apr 25 16:41:39 CST 2023. Universal Time is now: Tue Apr 25 08:41:39 UTC 2023. Is the above information OK? 1) Yes 2) No #? 1 You can make this change permanent for yourself by appending the line TZ='Asia/Shanghai'; export TZ to the file '.profile' in your home directory; then log out and log in again. Here is that TZ value again, this time on standard output so that you can use the /usr/bin/tzselect command in shell scripts: Asia/Shanghai ``` ## 重启corn ```bash systemctl restart crond ``` ## 写个测试脚本 ```crontab 57 16 * * * touch /tmp/111 ``` 看看文件是否创建成功 © 允许规范转载 打赏 赞赏作者 支付宝微信 赞 如果觉得我的文章对你有用,请随意赞赏