Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Debian buster show wrong date format

Linux Kernel, Network, and Services configuration.
Message
Author
kdillen
Posts: 11
Joined: 2019-07-30 08:33

Debian buster show wrong date format

#1 Post by kdillen »

Hello All,

I have done a few upgrades from Stretch to Buster and also a clean install of Buster and I run into an annoying issue with the date command:

When executed on Buster I have the following output:

Code: Select all

 root  /  etc  default  date
Tue 30 Jul 2019 11:29:54 AM CEST
 root  /  etc  default 
Expected output:

Code: Select all

 root  ~  date
Tue Jul 30 11:30:36 CEST 2019
 root  ~ 
This happen for both the upgrades and the clean install. And yes my timezone should be configured correctly.

Code: Select all

 root  ~  timedatectl status
               Local time: Tue 2019-07-30 11:49:09 CEST
           Universal time: Tue 2019-07-30 09:49:09 UTC
                 RTC time: Tue 2019-07-30 09:49:10
                Time zone: Europe/Brussels (CEST, +0200)
System clock synchronized: yes
              NTP service: inactive
          RTC in local TZ: no
 root  ~ 
Any idea how to get the same output from the date command in buster like in stretch ?

NOTE: dmesg / rsyslog etc.. all show the good output. Only on command line the `date` command give's the bad layout.

Thanks in advance.

L_V
Posts: 1477
Joined: 2007-03-19 09:04
Been thanked: 11 times

Re: Debian buster show wrong date format

#2 Post by L_V »

For investigation only:

Code: Select all

apt policy coreutils
+ what are those strange characters in your prompt ?

Code: Select all

 root  ~ 
(I see two squares) +

Code: Select all

echo $PS1

kdillen
Posts: 11
Joined: 2019-07-30 08:33

Re: Debian buster show wrong date format

#3 Post by kdillen »

Result:

Code: Select all

root  ~  apt policy coreutils
coreutils:
  Installed: 8.30-3
  Candidate: 8.30-3
  Version table:
 *** 8.30-3 500
        500 http://ftp.be.debian.org/debian buster/main amd64 Packages
        100 /var/lib/dpkg/status
 root  ~ 
Note the special characters come from powerline. Which I also use on stretch and other linux distro's

L_V
Posts: 1477
Joined: 2007-03-19 09:04
Been thanked: 11 times

Re: Debian buster show wrong date format

#4 Post by L_V »

For investigation

Code: Select all

# dpkg-reconfigure tzdata
Last edited by L_V on 2019-07-30 11:32, edited 1 time in total.

User avatar
Soul Singin'
Posts: 1605
Joined: 2008-12-21 07:02

Re: Debian buster show wrong date format

#5 Post by Soul Singin' »

Code: Select all

# apt-get install locales
# dpkg-reconfigure locales
The second of those commands will help you select your preference.

Here are the selected locales on my machine:

Code: Select all

$ locale 
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
Here's the list of available locales:

Code: Select all

$ locale -a 
C
C.UTF-8
en_US.utf8
POSIX
And here are the date formats:

Code: Select all

$ date 
Tue 30 Jul 2019 08:11:40 AM EDT
$ 
$ export LC_TIME="C.UTF-8"
$ date 
Tue Jul 30 08:11:49 EDT 2019
$ 
$ export LC_TIME="en_US.utf8"
$ date 
Tue 30 Jul 2019 08:11:56 AM EDT

kdillen
Posts: 11
Joined: 2019-07-30 08:33

Re: Debian buster show wrong date format

#6 Post by kdillen »

L_V wrote:For investigation

Code: Select all

# dpkg-reconfigure tzdata
Result:

Code: Select all

root  ~  dpkg-reconfigure tzdata

Current default time zone: 'Europe/Brussels'
Local time is now:      Tue Jul 30 15:21:44 CEST 2019.
Universal Time is now:  Tue Jul 30 13:21:44 UTC 2019.

root  ~  date
Tue 30 Jul 2019 03:22:21 PM CEST
root  ~ 
stays the same.

Note the strange thing it is happened on the updated systems from stretch to buster and on a clean install.

kdillen
Posts: 11
Joined: 2019-07-30 08:33

Re: Debian buster show wrong date format

#7 Post by kdillen »

Soul Singin' wrote:

Code: Select all

# apt-get install locales
# dpkg-reconfigure locales
The second of those commands will help you select your preference.

Here are the selected locales on my machine:

Code: Select all

$ locale 
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
Here's the list of available locales:

Code: Select all

$ locale -a 
C
C.UTF-8
en_US.utf8
POSIX
And here are the date formats:

Code: Select all

$ date 
Tue 30 Jul 2019 08:11:40 AM EDT
$ 
$ export LC_TIME="C.UTF-8"
$ date 
Tue Jul 30 08:11:49 EDT 2019
$ 
$ export LC_TIME="en_US.utf8"
$ date 
Tue 30 Jul 2019 08:11:56 AM EDT
Tried all these steps the result stays the same for me

I also tried to change to another timezone file from Europe/Brussels to Europe/Amsterdam it stay the same.

And the output from locale is the same on Stretch as on Buster. But in Stretch it works perfectly.

L_V
Posts: 1477
Joined: 2007-03-19 09:04
Been thanked: 11 times

Re: Debian buster show wrong date format

#8 Post by L_V »

No reason that locales could disappear during an update.
and this ?

Code: Select all

printenv | grep LANG

kdillen
Posts: 11
Joined: 2019-07-30 08:33

Re: Debian buster show wrong date format

#9 Post by kdillen »

L_V wrote:No reason that locales could disappear during an update.
and this ?

Code: Select all

printenv | grep LANG
Results from Buster:

Code: Select all

root  ~  cat /etc/debian_version
10.0
root  ~  printenv | grep LANG
LANG=en_US.UTF-8
root  ~  date
Tue 30 Jul 2019 03:33:52 PM CEST
root  ~ 
Results from stretch:

Code: Select all

root  ~  cat /etc/debian_version
9.9
root  ~  printenv | grep LANG
LANG=en_US.UTF-8
LANGUAGE=en_US:en
root  ~  date
Tue Jul 30 15:35:03 CEST 2019
root  ~ 

L_V
Posts: 1477
Joined: 2007-03-19 09:04
Been thanked: 11 times

Re: Debian buster show wrong date format

#10 Post by L_V »

Then your environement is not correct, and this

Code: Select all

ls -l /etc/localtime 
If not OK, try this

Code: Select all

rm /etc/localtime
ln -s /etc/localtime /usr/share/zoneinfo/Europe/Brussels

kdillen
Posts: 11
Joined: 2019-07-30 08:33

Re: Debian buster show wrong date format

#11 Post by kdillen »

L_V wrote:Then your environement is not correct, and this

Code: Select all

ls -l /etc/localtime 
If not OK, try this

Code: Select all

rm /etc/localtime
ln -s /etc/localtime /usr/share/zoneinfo/Europe/Brussels

Code: Select all

root  ~  ls -l /etc/localtime
lrwxrwxrwx 1 root root 35 Jul 30 15:27 /etc/localtime -> /usr/share/zoneinfo/Europe/Brussels
root  ~ 
As you notice there is no reason why it would not be correct. Everything is as it should be configured and the same as on stretch but in Buster is has strange results. Also as far as I can see in the log files is everything ok only the `date` command gives problems. But yeah some of my scripts depend on the correct date output format.


Example of logfile output:

Code: Select all

root  ~  cd /var/log
root  /  var  log  tail syslog
Jul 30 15:39:01 hostname systemd[1]: Starting Clean php session files...
Jul 30 15:39:01 hostname systemd[1]: phpsessionclean.service: Succeeded.
Jul 30 15:39:01 hostname systemd[1]: Started Clean php session files.
Jul 30 15:41:42 hostname systemd[1]: Starting Collect apt metrics for prometheus-node-exporter...
Jul 30 15:41:42 hostname systemd[1]: Starting Collect SMART metrics for prometheus-node-exporter...
Jul 30 15:41:42 hostname systemd[1]: prometheus-node-exporter-apt.service: Succeeded.
Jul 30 15:41:42 hostname systemd[1]: Started Collect apt metrics for prometheus-node-exporter.
Jul 30 15:41:43 hostname systemd[1]: prometheus-node-exporter-smartmon.service: Succeeded.
Jul 30 15:41:43 hostname systemd[1]: Started Collect SMART metrics for prometheus-node-exporter.
Jul 30 15:45:01 hostname CRON[8751]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
 root  /  var  log 

kdillen
Posts: 11
Joined: 2019-07-30 08:33

Re: Debian buster show wrong date format

#12 Post by kdillen »

It does not seems to be an issue with coreutils neither

Code: Select all

 root  /  var  log  /upgrade/date
Tue 30 Jul 2019 03:49:35 PM CEST
root  /  var  log  /upgrade/date  --version
date (GNU coreutils) 8.26
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by David MacKenzie.

root  /  var  log  date --version
date (GNU coreutils) 8.30
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by David MacKenzie.
root  /  var  log 
I copied the date command from stretch on an shared NFS and then used this on buster. With the same result.

L_V
Posts: 1477
Joined: 2007-03-19 09:04
Been thanked: 11 times

Re: Debian buster show wrong date format

#13 Post by L_V »

Try to add this in /etc/environment (or create if not exist).

Code: Select all

LC_TIME="fr_FR.UTF-8"
(and reboot for test / I think)

trinidad
Posts: 290
Joined: 2016-08-04 14:58
Been thanked: 14 times

Re: Debian buster show wrong date format

#14 Post by trinidad »

You can't believe your eyes if your imagination is out of focus.

kdillen
Posts: 11
Joined: 2019-07-30 08:33

Re: Debian buster show wrong date format

#15 Post by kdillen »

L_V wrote:Try to add this in /etc/environment (or create if not exist).

Code: Select all

LC_TIME="fr_FR.UTF-8"
(and reboot for test / I think)
Reboot is not needed.

Some test results:

Code: Select all

 root  /  var  log  export LC_TIME="en_US.UTF-8"
root  /  var  log  date
Tue 30 Jul 2019 03:58:20 PM CEST
root  /  var  log  export LC_TIME="fr_FR.UTF-8"
-bash: warning: setlocale: LC_TIME: cannot change locale (fr_FR.UTF-8)
root  /  var  log  date
mardi 30 juillet 2019, 15:58:35 (UTC+0200)
root  /  var  log 
So it seems related to the locale settings. But then the big problem is to find one that works for Belgium and is in English

And why it used to work before with stretch and now suddenly not anymore.

kdillen
Posts: 11
Joined: 2019-07-30 08:33

Re: Debian buster show wrong date format

#16 Post by kdillen »

Thank you for your imput. But I am sure it is not related to the powerline configuration. In that case I should have the same problem in Stretch. My systems and configurations are kept inline using ansible so both stretch as buster have the same powerline configuration and I not use the Powerlevel9k theme .

kdillen
Posts: 11
Joined: 2019-07-30 08:33

Re: Debian buster show wrong date format

#17 Post by kdillen »

for now I have a temporary fix:

Code: Select all

root  /  var  log  export LC_TIME="en_IE.UTF-8"
-bash: warning: setlocale: LC_TIME: cannot change locale (en_IE.UTF-8): No such file or directory
root  /  var  log  date
Tue Jul 30 16:03:55 CEST 2019
root  /  etc  locale -a
C
C.UTF-8
en_IE.utf8
en_US.utf8
 1 export LC_TIME="en_IE.UTF-8"
POSIX
root  /  etc  locale
LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME=en_IE.UTF-8
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
 root  /  etc  date
Tue Jul 30 16:05:36 CEST 2019
  blackcobra  root  /  etc 

L_V
Posts: 1477
Joined: 2007-03-19 09:04
Been thanked: 11 times

Re: Debian buster show wrong date format

#18 Post by L_V »

Some mystery .... sometimes

Expected output: Tue Jul 30 11:30:36 CEST 2019
Is this what you want, or close to ?

Code: Select all

date +%c
If your problem in the date format in script, I wonder if this kind of format is not more relevant like

Code: Select all

date +%Y%m%d-%H:%M
+

Code: Select all

man date
May be a date string to export.
I cannot do more. Sorry.

kdillen
Posts: 11
Joined: 2019-07-30 08:33

Re: Debian buster show wrong date format

#19 Post by kdillen »

L_V wrote:Some mystery .... sometimes

Expected output: Tue Jul 30 11:30:36 CEST 2019
Is this what you want, or close to ?

Code: Select all

date +%c
If your problem in the date format in script, I wonder if this kind of format is not more relevant like

Code: Select all

date +%Y%m%d-%H:%M
+

Code: Select all

man date
May be a date string to export.
I cannot do more. Sorry.
Well I have for me the workaround. I use now an export to set this "LC_TIME=en_IE.UTF-8" when I login. But in the end it should get fixed at some other level. I am not even sure if I had this problem when I was running buster when it was still in testing phase.

I hope they fix it. But my work around helps me at least.

L_V
Posts: 1477
Joined: 2007-03-19 09:04
Been thanked: 11 times

Re: Debian buster show wrong date format

#20 Post by L_V »

kdillen wrote:I hope they fix it.
Sorry but behavior of Buster seems more logical.
Can only be fixed what is clearly identified as a "bug". Check buglist, who knows.
Or ... re-investigate your scripts.... (=> convert date to something more consistent like date +%Y%m%d-%H:%M )

Post Reply