[精讚] [會員登入]
3078

在ESXI6.7修改系統時間

how to modify esxi system time setting for good

分享此文連結 //n.sfs.tw/15087

分享連結 在ESXI6.7修改系統時間@外行中的外行
(文章歡迎轉載,務必尊重版權註明連結來源)
最後編修
2021-05-07 22:44:09 By jung
 

 

最近想說白天不在家就把ESXI host關機以減少用電

於是理所當然的用LINUX的角度來解決,就是設定crontab

但是ESXI是vmware自行開發的核心

所以雖然有crontab功能,但設定上不太相同

首先找到crontab

/var/spool/cron/crontabs/root

直接用vi 修改,並強制儲存:wq!

但只要重開機就洗掉了

要改 ESXi 開機 script 之一的 /etc/rc.local.d/local.sh

vi 修該之後,要強制寫入

在檔案底部最後一行 exit 0 前加入

kill $(cat /var/run/crond.pid)
echo "your crontab setting command" >> /var/spool/cron/crontabs/root
crond

解決了crontab 卻發現怎麼做都沒有執行

原來是系統時間出問題

先解決ubuntu vm

預設安裝完就是UTC時區

所以要改成Asia/Taipei

先用 timedatectl list-timezones 觀察可用的時區設定

再直接用  timedatectl set-timezone Asia/Taipei 設定完成

可惜ESXI 就沒那麼好懂

查了網路文章,都說esxi 預設就是UTC改不了,就算改NTP server都沒用

只好試試看一篇中國的技術文章,結果有效!

先到linux vm去找到/etc/localtime 這個檔案,裡面都是給機器讀的二進位代碼

不過只要linux 時區設定正確,就直接複製這個檔案,放到ESXI的儲存區,再強迫ESXI取代原本的localtime檔案就好

先用檔案總管上傳一般設定好的linux /etc/localtime檔案到ESXI 的目錄下

再把檔案強制回寫到ESXI 的 localtime

cp /vmfs/volumes/your_data_store/folder/ /etc/localtime

這樣使用命令列查詢時間就是本地時間了

但是在ESXI 6.7 的網頁管理界面還是顯示UTC時區

雖然很奇怪,不過這樣就是完成了

最後當然還是要到 /etc/rc.local.d/local.sh 去改設定

最後一行加上 cp -f /vmfs/volumes/your_data_store_location/localtime /etc/localtime

就完成

以上參考下列網站,感謝各位先進

https://blog.51cto.com/jdonghong/1957118

https://linuxize.com/post/how-to-set-or-change-timezone-on-ubuntu-20-04/

https://andersonwang.wordpress.com/2019/02/22/%E7%B7%A8%E8%BC%AF-esxi-6-7-%E7%9A%84-crontab/

 

END

你可能感興趣的文章

bitbucket repository control application setup 安裝完bitbucket服務後,須設定bitbucket.properties

logrotate執行權限問題 logrotate will failed to execute if selinux policy not setup correctly

JIRA using gmail as smtp outgoing mail sender 如何設定jira使用gmail信箱送信

how to add physical disks into HP smart array through esxi interface 如何在磁碟陣列卡上加入新的硬碟-未完待續

JIRA instance migration phase1 how to migrate JIRA from centos6 to centos7

how to resolve memory allocation issue on proxmox when creating vm, sometimes the log shows fail message of Cannot_allocate_memory

隨機好文

縣市IDP更換SSL憑證及修改servername+wildfly等設定 縣市IDP更換SSL

bitbucket repository control application setup 安裝完bitbucket服務後,須設定bitbucket.properties

使用virtualbox每次都忘記的事情 share folder from win host to linux guest vm

在windows環境下強制刪除無法以檔案總管刪除的檔案或目錄 how to remove directories or files that cannot be deleted by default file manager

在ubuntu18.04桌面版安裝中文注音輸入法 如何在ubuntu桌面使用新酷音注音輸入法