Linode VPS 預設時區是美國時間,跑定時任務時很容易對不上,所以最好一開機就改掉。Linux 下改時區的指令是 tzselect。
執行後會先要你選洲別:
Please identify a location so that time zone rules can be set correctly. Please select a continent or ocean 1) Africa 6) Atlantic Ocean 2) Americas 7) Australia 3) Antarctica 8) Europe 9) Indian Ocean 10) Pacific Ocean 11) none - I want to specify the time zone using the Posix TZ format.
輸入 5 選亞洲,接著選國家/地區(清單很長,找到 9) China 或 43) Taiwan):
Please select a country ... 9) China ... 43) Taiwan ...
選中國之後再選時區區域:
Please select one of the following time zone regions 1) east China - Beijing, Guangdong, Shanghai, etc. 2) Heilongjiang 3) central China - Gansu, Guizhou, Sichuan, Yunnan, etc. 4) Tibet & most of Xinjiang Uyghur 5) southwest Xinjiang Uyghur
輸入 1 即北京時間。最後畫面會顯示推導結果並要求確認:
The following information has been given: China east China - Beijing, Guangdong, Shanghai, etc Therefore TZ="Asia/Shanghai" will be used. Local time is now: Fri Jul 7 10:32:18 CST 2006. Universal Time is now: Fri Jul 7 02:32:18 UTC 2006. Is the above information OK? 1) Yes 2) No
輸入 1 確認。若你在台灣,選 43) Taiwan 會得到 Asia/Taipei,兩者時區相同。
tzselect 只是幫你找出正確的 TZ 值,接著要寫進使用者的家目錄。編輯 .bash_profile,加入兩行:
TZ='Asia/Shanghai' export TZ
重新登入,或用 source 直接載入:
source ~/.bash_profile
最後用 date 確認系統時間是否正確:

補充:若要讓全系統(包含 root 與所有服務)都套用,除了上面的做法,也可以直接把時區檔連結過去:
ln -sf /usr/share/zoneinfo/Asia/Taipei /etc/localtime
新版 systemd 發行版則可用 timedatectl set-timezone Asia/Taipei 一行搞定,並以 timedatectl status 核對。改完時區後,若日誌時間仍舊怪怪的,記得檢查 /etc/timezone 與 cron 服務是否需要重啟。