Time and date incoherent between shell and "System/General"

enel

Cadet
Joined
Jul 4, 2023
Messages
1
Hello everyone!
I'm new in TRUENas, I have recently installed TRUENAS core into an old computer to give it a new life and now, I want to auto shutdown the server at a certain hour... I've read a post about it, and I've created a Cron job to execute the shutdown command the problem is that it's not executing correctly... or at least, at the time I want to...
I have set up the timezone in the "System/General" section. There I chose the timezone "Europe/Madrid" and in the "Time format" section I can see the actual time and date, correctly (21:08, for example), but if I go to the shell and type "date" it returns (23:08) it's +2h than it should be...
Reading other posts, I found one talking about the BIOS date, so I checked the BIOS date and time is correct and it also shows the actual date and time...
But the cron job is taking the shell time to execute the task, so everything will be executed +2h...
A "solution" could be set the cron job time 2h early i want to be executed, so then they will be executed on time, but I would like to know if there is a way to sync the time and date over the internet conection, for example, or just adjust the time using the same method as the "System/General" is using so I'll have the same time in all the sections...

I hope I explained well the issue I'd like to solve.

Thaaanks so much for the help in advance!!
 

HoneyBadger

actually does care
Administrator
Moderator
iXsystems
Joined
Feb 6, 2014
Messages
5,112
Hello @enel

TrueNAS expects that your hardware (BIOS) time be set in the UTC time zone - so as you are in UTC+0200, you would have to set your hardware clock to "two hours in the past" and then set your local time zone in System -> General -> Timezone to Europe/Madrid - this will give you the correct results.

Cheers!
 

jgreco

Resident Grinch
Joined
May 29, 2011
Messages
18,680
Reading other posts, I found one talking about the BIOS date, so I checked the BIOS date and time is correct and it also shows the actual date and time...

Your BIOS date needs to be set to *correct* computer time, which is UTC. Your local timezone is two hours off of UTC. Timezones are an affectation for the comfort of humans, but computers need a standardized time, and then they will transform that standardized time (time_t) into a localized interpretation. Your BIOS lacks the sophistication to know what timezone you are in, so when the system pulls the current time from the BIOS at boot time, if you have the CMOS set to local time, you will be off by some offset. If you have the CMOS set to UTC like you should, your local timeservice gets properly initialized with the correct (time_t) time, and then when you specify Europe/Madrid, anything trying to format the time for display applies a proper offset and displays what you might think of as your "local time".
 
Joined
Feb 21, 2022
Messages
4
Last edited:
Top