Stellen Sie die Debian-Linux-Zeitzone über die Befehlszeile ein

3929
Daniel Jørgensen

Gibt es eine Möglichkeit, die aktuelle Zeitzone über die Befehlszeile / das Terminal einzustellen? Es ist für ein Shelle-Skript, also suche ich hoffentlich einen Liner wie date -Z 'Europe/London'(Nur ein Beispiel), mit anderen Worten, nur einen Befehl zum Schreiben und nicht irgendetwas mit Grafiken

Gibt es eine eingebaute Möglichkeit, dies zu tun?

5

2 Antworten auf die Frage

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

You can change it with more than one line. Exactly two lines.

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

and then Link your TimeZone file like this:

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

You can check with date

In neueren Versionen von systemd kann auch https://wiki.archlinux.org/index.php/time#Time_zone verwendet werden larkey vor 8 Jahren 1
Vielen Dank! Auch gut zu wissen ;-) Ich bin nicht so vertraut mit systemd ... SystemCookie vor 8 Jahren 0