[精讚] [會員登入]
2496

在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

你可能感興趣的文章

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

在windows server建立radius服務使用active directory帳號驗證 setup windows server to add radius service using active directory accounts for authentication

proxmox5.x using duplicati as cloud backup strategy install duplicati program on Proxmox host for remote backup using google drive account

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

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

IIS10設定url rewrite to https if you setup url rewrite function in IIS10, might cause api callback failed

我有話要說

>>

限制:留言最高字數1000字。 限制:未登入訪客,每則留言間隔需超過10分鐘,每日最多5則留言。

訪客留言

[無留言]

隨機好文

[網管心得]ssh keygen用法 ssh-copy-id

縣市IDP新增API功能 修改IDP程式增加API介面

在debian9使用apt-key add gpg key from ubuntu keyserver

proxmox5.x using duplicati as cloud backup strategy install duplicati program on Proxmox host for remote backup using google drive account

intellij IDEA git設定說明 whenever using git push fuction in the intellij IDEA