Correct time in Raspberry Pi 5

March 11, 2024, 08:51

rey.1576

How can I update my date and time

rey.1576

Somebody help me I'm using raspberry pi 5

oops.se

It depends on what kind of Pi model you have and your expectations. With a Raspberry Pi 5 you have a built in RTC and can connect a battery, that will keep the date and time accurate when when the Pi is powered off. You can add a RTC to other models also but that include adding hardware and a battery. If you wish to keep the date and time accurate you can sync it against precision clocks on the internet via NTP (Network Time Protocol). Install ntp, udo apt install ntp and you can also tweak it so it uses the closest geographically by changing the NTP source to a close NTP Pool, check https://www.ntppool.org/en/

rey.1576

Can you assist me setting up the ntp?

oops.se

Yes

oops.se

Open a terminal

oops.se

and type sudo apt install ntp

rey.1576

I've tried setting up it before but it doesn't show nothing

rey.1576

Done

oops.se

and type sudo service ntp ststus

oops.se

And post the output and no pictures plz

rey.1576

It says active and enabled

oops.se

Nice, then it will adjust the clock/date to be correct.

oops.se

But it doesn't change it directly it will adjust it over a period of time

oops.se

So withing a hour or two it will be todays time/date

oops.se

If you wish to force the date/time directly there is a way (command)

rey.1576

I've been on for so long but it's still not up to date

rey.1576

How?

oops.se

you need to install datectrl

rey.1576

Thanks

oops.se

I will change the topic so it reflects what you asked for

rey.1576

<@796000224690307072> i tried installing datectrl it said Unable to locate package datectrl

rey.1576

By using command sudo apt install datectrl

oops.se

Correct, my bad its in Ubuntu

oops.se

In debian the command is timedatectl

rey.1576

I'm using raspberry pi os

rey.1576

Okay

oops.se

Raspberry Pi OS is a built on Debian

oops.se

So this link should be appropriate for you https://phoenixnap.com/kb/debian-time-sync

rey.1576

It says the same thing Unable to locate package timedatectl

oops.se

But if you have set the timezone with raspi-configthere is no need to do it again

oops.se

Then you need to install it

rey.1576

I'm having this problem with other apt installing

oops.se

What problem?

rey.1576

Like unlocate package

rey.1576

I tried this thing before but it doesn't change the date

oops.se

Ok basic apt: First you need to keep it updated, so run: sudo apt update This will update the database over all packages you can install

oops.se

Then you need to install the package you need: sudo apt install dateutils

oops.se

You can also upgrade old versions of packages: sudo apt upgrade

oops.se

And why sudo before apt? sudo is raising your privilegie to administrator from normal user. A normal user can't install programs, but a administrator can install programs.

oops.se

This is a security feature

oops.se

And apt is the command for installing, uninstalling and to do other stuf with programs in Debian

rey.1576

I tried to sudo apt update but it also show an error

oops.se

What error? Or should I guess?

rey.1576

Release file error

oops.se

Post the complete error and the exact error text

rey.1576

E: Release file for http://deb.deblan.org/debian/dists/bookvorm/InRe lease 1s not valid yet (invalid for another 67d 4h 32min 17s). Updates for this repository MIlL not be applied. E: Release rile for nttp://deb, debian.org/debian- security/dists/bookworm-security/InRelease 1s not varid yet (invalid for another 96d 23n 18min 33s). Updates for this repository Mill not be applied E: Release f1le or http://deb.debian.org/debian/dists/bookworm-updates/InRelease 1s not valid yet (invalid ror another 97d 1n 43min 47s). updates for this repository will not be applied, E: Release f1le for http://archive.raspberrypi.com/debian/dists/bookworm/InRelease 1s o not va valld yet ( Xva invalid td ToT for ao another tler 97d on 0n 56min 5omin 6s). 6s). Updates Updates for for this this repository repository will will not not be be applied

oops.se

There is a spelling error: http://deb.deblan.org/debian/dists/bookvorm/... http://deb.deblan.org/debian/dists/bookworm/... Bookworm is spelled with W and in the error it is spelled with V

oops.se

So you need to correct it: sudo nano /etc/apt/sources.list

rey.1576

Yeah it's not wrong there's a problem with my copying text through image

oops.se

Well the content of /etc/apt/sources.list should look like below:
deb http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware
deb http://deb.debian.org/debian-security/ bookworm-security main contrib non-free non-free-firmware
deb http://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware

rey.1576

Everything looks fine but i don't know why

oops.se

Reboot

rey.1576

Done rebooting still having a problem with updating

oops.se

Without a correct error I am unable to assist you