Eventually my Pi will help me when I’m making my famous home brew. However to do that I need it to keep accurate time.
If you already own a Raspberry Pi then you will know that there is no real time clock. The solution to this is to use NTP (Network time protocol) connecting to a time server.
To check the current system time type ‘date’ from a shell
This is where my Pi falls over. It will not keep accurate time.
To rectify this you have to alter a system config file, but first we will be backing up this file just in case of any mistakes.
The file in question is called ntp.conf and can be found in the /etc folder.
To back up the file type the following:
‘sudo cp /etc/ntp.conf /etc/ntp_backup.conf’
into your shell. If you are like me and using your Pi as a headless server then logging in using ssh will land you at a command line. If your using the desktop then start up a command line from the shortcut on your desktop.
Right, next is setting the time servers. I live in the UK so these will be set to ones within the UK.
Type ‘sudo nano /etc/ntp.conf’
you will see on the page something like this:
server 0.pool.ntp.org iburst
server 1.pool.ntp.org iburst
server 2.pool.ntp.org iburst
server 3.pool.ntp.org iburst
Change this to your local time servers. Navigate to http://www.pool.ntp.org/en/use.html to find yours.
Example if your in the UK you should change the entry in your ntp.conf file so it looks like this.
server 0.uk.pool.ntp.org iburst
server 1.uk.pool.ntp.org iburst
server 2.uk.pool.ntp.org iburst
server 3.uk.pool.ntp.org iburst
Finally further down the file you will see the following:
restrict 127.0.0.1
restrict ::1
comment these out by inserting a ‘#’ (without quotes) at the beginning of these lines
press crtl + x then ‘Y’ will save your changes
Ok now that is done the next stage is to update the time. you can reboot or:
type ‘sudo service ntp restart’
followed by ‘date’
You now should have the current time and date displayed every time you type ‘date’
Happy time keeping 🙂