2

My raspberry was wrong time and date. I run 'ps auxwww | grep ntp' and i get:

pi 7282 0.0 0.1 4248 1480 pts/0 S+ 05:50 0:00 grep --color=auto ntp

So i don't have ntp service running..

sudo systemctl status ntp.service

 ● ntp.service - LSB: Start NTP daemon
  Loaded: loaded (/etc/init.d/ntp)
  Active: failed (Result: exit-code) since Fri 2017-03-03 05:42:47 WET; 9min ago
  Process: 5126 ExecStart=/etc/init.d/ntp start (code=exited, status=2)

Mar 03 05:42:47 raspberrypi ntp[5126]: /etc/init.d/ntp: 6: /lib/lsb/init-functions.d/20-left-info-blocks: Syntax er...pected
Mar 03 05:42:47 raspberrypi systemd[1]: ntp.service: control process exited, code=exited status=2
Mar 03 05:42:47 raspberrypi systemd[1]: Failed to start LSB: Start NTP daemon.
Mar 03 05:42:47 raspberrypi systemd[1]: Unit ntp.service entered failed state.
Hint: Some lines were ellipsized, use -l to show in full

If i trỹ install again ntp, gives so many errors:

sudo apt-get install ntp
Reading package lists... Done
Building dependency tree       
Reading state information... Done
ntp is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 24 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Can't set locale; make sure $LC_* and $LANG are correct!
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_TIME = "pt_PT.UTF-8",
LC_MONETARY = "pt_PT.UTF-8",
LC_CTYPE = "pt_PT.UTF-8",
LC_ADDRESS = "pt_PT.UTF-8",
LC_TELEPHONE = "pt_PT.UTF-8",
LC_NAME = "pt_PT.UTF-8",
LC_MEASUREMENT = "pt_PT.UTF-8",
LC_IDENTIFICATION = "pt_PT.UTF-8",
LC_NUMERIC = "pt_PT.UTF-8",
LC_PAPER = "pt_PT.UTF-8",
LANG = "en_GB.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_GB.UTF-8").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
Setting up ntp (1:4.2.6.p5+dfsg-7+deb8u2) ...
update-rc.d: warning: start and stop actions are no longer supported;  falling back to defaults
Job for ntp.service failed. See 'systemctl status ntp.service' and   'journalctl -xn' for details.
invoke-rc.d: initscript ntp, action "start" failed.
dpkg: error processing package ntp (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
ntp
E: Sub-process /usr/bin/dpkg returned an error code (1)

I read many similar problems but none helped me ..

I tried solve the locale problem, but gives me identical error:

sudo dpkg-reconfigure locales
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_PAPER = "pt_PT.UTF-8",
LC_ADDRESS = "pt_PT.UTF-8",
LC_MONETARY = "pt_PT.UTF-8",
LC_NUMERIC = "pt_PT.UTF-8",
LC_TELEPHONE = "pt_PT.UTF-8",
LC_IDENTIFICATION = "pt_PT.UTF-8",
LC_MEASUREMENT = "pt_PT.UTF-8",
LC_CTYPE = "pt_PT.UTF-8",
LC_TIME = "pt_PT.UTF-8",
LC_NAME = "pt_PT.UTF-8",
LANG = "en_GB.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_GB.UTF-8").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
/usr/bin/locale: Cannot set LC_CTYPE to default locale: No such file or directory
/usr/bin/locale: Cannot set LC_ALL to default locale: No such file or directory
 Generating locales (this might take a while)...
 en_GB.UTF-8... done
 Generation complete.
 perl: warning: Setting locale failed.
 perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_TIME = "pt_PT.UTF-8",
LC_MONETARY = "pt_PT.UTF-8",
LC_CTYPE = "pt_PT.UTF-8",
LC_ADDRESS = "pt_PT.UTF-8",
LC_TELEPHONE = "pt_PT.UTF-8",
LC_NAME = "pt_PT.UTF-8",
LC_MEASUREMENT = "pt_PT.UTF-8",
LC_IDENTIFICATION = "pt_PT.UTF-8",
LC_NUMERIC = "pt_PT.UTF-8",
LC_PAPER = "pt_PT.UTF-8",
LANG = "C"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_TIME = "pt_PT.UTF-8",
LC_MONETARY = "pt_PT.UTF-8",
LC_CTYPE = "pt_PT.UTF-8",
LC_ADDRESS = "pt_PT.UTF-8",
LC_TELEPHONE = "pt_PT.UTF-8",
LC_NAME = "pt_PT.UTF-8",
LC_MEASUREMENT = "pt_PT.UTF-8",
LC_IDENTIFICATION = "pt_PT.UTF-8",
LC_NUMERIC = "pt_PT.UTF-8",
LC_PAPER = "pt_PT.UTF-8",
LANG = "C"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

How can i update Raspberry Time/Date automatically?

  • 2
    Solve the locale issue first. Reinstalling software because of an error you do not understand is a cargo cult activity. By analogy, if I have a toaster that fails to make toast because it is not plugged in, but I do not understand toasters and so assume it is broken, buying a new toaster will not fix the problem and only result in me wasting time and money. – goldilocks Mar 6 '17 at 10:43
  • Also I think the OP needs to check if he/she is actually connected to the Internet. If the ntp server does not respond, I don't assume the date will be updated. – Shan-Desai Mar 6 '17 at 10:45
  • I tried solve the locale problem. I run sudo locale-gen pt_PT pt_PT.UTF-8 and sudo dpkg-reconfigure locales but the last one gives me the same error.. – R. Rodrigues Mar 6 '17 at 10:55
  • @R.Rodrigues what about sudo /etc/init.d/ntp restart and then date does it give you something? Also are you ssh'ing into your Pi? – Shan-Desai Mar 6 '17 at 11:16
  • Yes i'm acessing with ssh... – R. Rodrigues Mar 6 '17 at 11:22
1

Locale Issue

Since you are accessing your Pi overssh, I think the following methods might help you solve the locale errors.

  • Stop forwarding your machine's locale to the Raspberry Pi. Simple comment out the following line in your machines /etc/ssh/ssh_config file:

    # SendEnv LANG LC_*
    

    This will stop sending your Portuguese locale to your raspberry pi.

  • You can try generating Portuguese locale on the Pi: sudo locale-gen pt

  • You can set explicitly English to your Pi by writing into ~/.bashrc (try LANGUAGE = "pt" for Portuguese):

    export LANGUAGE="en"
    export LANG="C"
    export LC_MESSAGES="C"
    

NTP Issues

I am not sure if your Pi is connected to public internet, if so you can just ping Google:

ping -c3 8.8.8.8

If the ping is not reachable that means you are not connected to the public Internet.

If your internal network has a properly configured NTP. try resetting using :

sudo /etc/init.d/ntp stop
sudo ntpd -qg
sudo /etc/init.d/ntp start

and then try date. I think this should get your work done.

Sources

AskUbuntuSE Thread for setting locale failed

  • I get this error, when tried stop ntp: sudo /etc/init.d/ntp stop /etc/init.d/ntp: 6: /lib/lsb/init-functions.d/20-left-info-blocks: Syntax error: "}" unexpected – R. Rodrigues Mar 6 '17 at 12:15
  • try sudo systemctl stop ntp.service and perform the /etc/init.d/ again? see if that helps? – Shan-Desai Mar 6 '17 at 12:33
  • No, it's the same thing – R. Rodrigues Mar 6 '17 at 15:44
  • The service was already stopped .., when i tried stop again, gives me the same error – R. Rodrigues Mar 6 '17 at 15:45
  • okay. maybe one last try. sudo apt-get remove --purge ntp and finally sudo apt-get install ntp. – Shan-Desai Mar 6 '17 at 15:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.