[pve-devel] [PATCH manager 1/1] Fix #7175: use timedatectl for timezone handling

Stefan Mayr stefan at mayr-stefan.de
Thu Dec 25 09:05:24 CET 2025


Suggested-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
Signed-off-by: Stefan Mayr <stefan at mayr-stefan.de>
---
 PVE/API2/Nodes.pm | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm
index 6a6465b6..54ed712e 100644
--- a/PVE/API2/Nodes.pm
+++ b/PVE/API2/Nodes.pm
@@ -1582,10 +1582,15 @@ __PACKAGE__->register_method({
     code => sub {
         my ($param) = @_;
 
+        my $timezone;
         my $ctime = time();
         my $ltime = timegm_nocheck(localtime($ctime));
+        PVE::Tools::run_command(
+            ['timedatectl', 'show', '--property=Timezone', '--value'],
+            outfunc => sub { $timezone //= shift },
+        );
         my $res = {
-            timezone => PVE::INotify::read_file('timezone'),
+            timezone => $timezone,
             time => $ctime,
             localtime => $ltime,
         };
@@ -1619,7 +1624,7 @@ __PACKAGE__->register_method({
     code => sub {
         my ($param) = @_;
 
-        PVE::INotify::write_file('timezone', $param->{timezone});
+        PVE::Tools::run_command(['timedatectl', 'set-timezone', $param->{timezone}]);
 
         return;
     },
-- 
2.34.1




More information about the pve-devel mailing list