linux設(shè)置時(shí)間同步命令Linux設(shè)置時(shí)間和查看時(shí)間
linux設(shè)置時(shí)間同步命令Linux設(shè)置時(shí)間和查看時(shí)間
本文主要講解如何修改Linux的系統(tǒng)時(shí)間和設(shè)置系統(tǒng)時(shí)間。2.查看當(dāng)前系統(tǒng)時(shí)間。[root@zcwyou ~]# date查看當(dāng)前系統(tǒng)時(shí)間。2019年 03月 10日 星期日 22:11:35 CST。默認(rèn)輸入分別是星期、月份、日、時(shí)間、時(shí)區(qū)、年份。[root@zcwyou ~]# date +%D10/12/19。月/日/年;按月/日/年格式輸出時(shí)間。3.自定義輸出格式;中國(guó)人的習(xí)慣年/月/日。[root@zcwyou ~]# date +";%Y-%m-%d";2019-10-12。%Y表示年;%m表示月;%d表示日;[root@zcwyou ~]# date +";%Y-%m-%d %H:%M.%S";2019-10-12 05:46.46。%H表示時(shí);
導(dǎo)讀本文主要講解如何修改Linux的系統(tǒng)時(shí)間和設(shè)置系統(tǒng)時(shí)間。2.查看當(dāng)前系統(tǒng)時(shí)間。[root@zcwyou ~]# date查看當(dāng)前系統(tǒng)時(shí)間。2019年 03月 10日 星期日 22:11:35 CST。默認(rèn)輸入分別是星期、月份、日、時(shí)間、時(shí)區(qū)、年份。[root@zcwyou ~]# date +%D10/12/19。月/日/年;按月/日/年格式輸出時(shí)間。3.自定義輸出格式;中國(guó)人的習(xí)慣年/月/日。[root@zcwyou ~]# date +";%Y-%m-%d";2019-10-12。%Y表示年;%m表示月;%d表示日;[root@zcwyou ~]# date +";%Y-%m-%d %H:%M.%S";2019-10-12 05:46.46。%H表示時(shí);
![](https://img.51dongshi.com/20241124/wz/18359214552.jpg)
1. date命令簡(jiǎn)介本文主要講解如何修改Linux的系統(tǒng)時(shí)間和設(shè)置系統(tǒng)時(shí)間。2. 查看當(dāng)前系統(tǒng)時(shí)間[root@zcwyou ~]# date查看當(dāng)前系統(tǒng)時(shí)間2019年 03月 10日 星期日 22:11:35 CST默認(rèn)輸入分別是星期、月份、日、時(shí)間、時(shí)區(qū)、年份。[root@zcwyou ~]# date +%D10/12/19月/日/年按月/日/年格式輸出時(shí)間3. 自定義輸出格式中國(guó)人的習(xí)慣年/月/日[root@zcwyou ~]# date +"%Y-%m-%d"2019-10-12%Y表示年%m表示月%d表示日[root@zcwyou ~]# date +"%Y-%m-%d %H:%M.%S"2019-10-12 05:46.46%H表示時(shí)%M表示分%S表示秒4. 輸出未來時(shí)間輸出100秒后的時(shí)間[root@zcwyou ~]# date -d "100 second" +"%Y-%m-%d %H:%M.%S"2019-10-12 05:50.49查看Linux100秒后的時(shí)間5. 設(shè)置系統(tǒng)時(shí)間5.1 設(shè)定年月日,重置時(shí)分秒查看當(dāng)前時(shí)間[root@zcwyou ~]# date +"%Y-%m-%d %H:%M.%S"2019-10-12 05:58.18設(shè)置時(shí)間為20191013[root@zcwyou ~]# date -s 20191013Sat Oct 13 00:00:00 EDT 2019驗(yàn)證:[root@zcwyou ~]# date +"%Y-%m-%d %H:%M.%S"2019-10-13 00:00.04發(fā)現(xiàn)重置了時(shí)分秒。5.2 設(shè)置時(shí)分秒,不影響日期[root@zcwyou ~]# date -s 06:02:15Sat Oct 13 06:02:15 EDT 20195.3 設(shè)置日期和時(shí)分秒方式1:[root@zcwyou ~]# date -s "06:05:30 2019-10-12" 5.4 設(shè)置日期和時(shí)分秒方式2:[root@zcwyou ~]# date -s "06:06:30 20191012" 5.5 設(shè)置日期和時(shí)分秒方式3:[root@zcwyou ~]# date -s "2019-10-12 06:07:30"5.6 設(shè)置日期和時(shí)分秒方式4:[root@zcwyou ~]# date -s "20191012 06:08:30" 6. 總結(jié)一般情況使用date來獲取系統(tǒng)時(shí)間,一般不會(huì)使用date命令來設(shè)置時(shí)間。
linux設(shè)置時(shí)間同步命令Linux設(shè)置時(shí)間和查看時(shí)間
本文主要講解如何修改Linux的系統(tǒng)時(shí)間和設(shè)置系統(tǒng)時(shí)間。2.查看當(dāng)前系統(tǒng)時(shí)間。[root@zcwyou ~]# date查看當(dāng)前系統(tǒng)時(shí)間。2019年 03月 10日 星期日 22:11:35 CST。默認(rèn)輸入分別是星期、月份、日、時(shí)間、時(shí)區(qū)、年份。[root@zcwyou ~]# date +%D10/12/19。月/日/年;按月/日/年格式輸出時(shí)間。3.自定義輸出格式;中國(guó)人的習(xí)慣年/月/日。[root@zcwyou ~]# date +";%Y-%m-%d";2019-10-12。%Y表示年;%m表示月;%d表示日;[root@zcwyou ~]# date +";%Y-%m-%d %H:%M.%S";2019-10-12 05:46.46。%H表示時(shí);
為你推薦