Установите Debian Linux Timezone через командную строку

3872
Daniel Jørgensen

Есть ли способ установить текущий часовой пояс через командную строку / терминал? Это для сценария шелле, так что я ищу, надеюсь, один лайнер, как date -Z 'Europe/London'(просто пример), другими словами, просто команду, чтобы написать, а не что-нибудь сделать с графикой

Есть ли способ сделать это?

5

2 ответа на вопрос

3
Xen2050

This works on Linux Mint, Ubuntu, Debian, I think most Debian-based distros...

echo "America/Eastern" | sudo tee /etc/timezone sudo dpkg-reconfigure --frontend noninteractive tzdata 

Where to find timezones:

Or (as commented) use timedatectl list-timezones to find a zone, then timedatectl set-timezone [timezone]


If required, see this Debian page about Time Zone Changes. You could use the program zic along with changing some files, if you wanted to change the details of the time zone, like daylight savings time start & end dates, etc.

2
SystemCookie

Вы можете изменить его более чем на одну строку. Ровно две строчки.

  1. mv /etc/localtime /etc/localtime.old

а затем свяжите ваш файл TimeZone следующим образом:

  1. ln -s /usr/share/zoneinfo/Europa/London /etc/localtime

Вы можете проверить с date

В более поздних версиях systemd также можно использовать https://wiki.archlinux.org/index.php/time#Time_zone larkey 8 лет назад 1
Спасибо! Также приятно знать ;-) Я не настолько знаком с systemd ... SystemCookie 8 лет назад 0

Похожие вопросы