Hot answers tagged

119 votes

Docker Container time & timezone (will not reflect changes)

Usually it is sufficient to set an environment variable in the docker container, like so: docker run -e TZ=Europe/Amsterdam debian:jessie date Of course this would work also with docker-compose.
Victor Klos's user avatar
  • 1,321
67 votes
Accepted

Why is the year in this ISO timestamp not 2019?

Most of the google hits show CODEBUILD_START_TIME being represented as the number of milliseconds since 1970. I suspect somewhere in your code you are treating that as if it were seconds. If you ...
Zoredache's user avatar
  • 132k
39 votes

Docker Container time & timezone (will not reflect changes)

You can add your local files (/etc/timezone and /etc/localtime) as volume in your docker-container. Update your docker-compose.yml with the following lines. volumes: - "/etc/timezone:/etc/...
Y4roc's user avatar
  • 491
20 votes

ansible manipulate file with a date format

Starting with 2.4, you can also use the strftime filter (doc): # Display year-month-day {{ '%Y-%m-%d' | strftime }} # Display hour:min:sec {{ '%H:%M:%S' | strftime }} # Use ansible_date_time.epoch ...
Davor Cubranic's user avatar
18 votes

Docker Container time & timezone (will not reflect changes)

In ubuntu 16.04 image there is bug. Solution was ENV TZ 'Europe/Tallinn' RUN echo $TZ > /etc/timezone && \ apt-get update && apt-get install -y tzdata && \ ...
qwerty's user avatar
  • 281
8 votes

Red hat Linux + TIME ZONE CONFIGURATION + details from clock file

With the introduction of RHEL 7 the timezone is managed through systemd, which provides a custom utility to change the timezone: timedatectl To list all available time zones: timedatectl list-...
HBruijn's user avatar
  • 80.2k
8 votes
Accepted

Ubuntu 18.04 strange behaviour of date with --date option

The problem here is that date is treating the +1 part as the timezone, and not as an extra minute. The extra minute is coming only from the word minutes which is parsed as "add one minute" because it ...
Moshe Katz's user avatar
  • 3,182
7 votes
Accepted

Change date on a computer that is attached to a domain

It's not recommended for a lot of reasons, but here is how to: First, unregister your time service to not resync. On elevated prompt run: W32TM /unregister Then, change set the time you want using ...
Felipe Donda's user avatar
6 votes
Accepted

Red hat Linux + TIME ZONE CONFIGURATION + details from clock file

So the "correct" way to set the clock (at least prior to RHEL 7) is to edit /etc/sysconfig/clock and then run tzdata-update which will then update /etc/localtime; you've just done that step manually.
bodgit's user avatar
  • 4,771
6 votes

Incorrect Ubuntu server time

How to keep accurate time on Ubuntu continuously? By enabling the ntpd service and running it continuously. I synchronized it using sudo ntpdate -s time.nist.gov few months ago but it jumped ...
HBruijn's user avatar
  • 80.2k
6 votes

Incorrect Ubuntu server time

Unfortunately Ubuntu hasn't added the disclaimer from NTP.org's ntp-4.2.*\html\ntpdate.html manual to Ubuntu's ntpdate(8) manpage, like for example FreeBSD has: ntpdate - set the date and time via ...
Esa Jokinen's user avatar
  • 49.7k
6 votes
Accepted

Redhat Enterprise Linux 7: How to disable DST - Daylight Saving Time

You don't disable DST per se, you set the desired time zone, and you get DST if the time zone has DST. You can check the configured time zone with timedatectl. If your timezone has DST you'll see ...
Michael Hampton's user avatar
5 votes

Creating a RFC 1123 compliant date for HTTP header creation on the CLI

env TZ=GMT; date '+%a, %d %b %Y %T %Z' %T is equivalent to %H:%M:%S. %Z is replaced by the time zone name. The solution by @brad, DATE=$(date -u +%a,\ %d\ %b\ %Y\ %H:%M:%S\ GMT), would be incorrect ...
Weihang Jian's user avatar
5 votes

Docker Container time & timezone (will not reflect changes)

Adding my two cents here, because I've tried several of these but none worked on alpine-based images. However, this did the trick: ENV TZ=America/Toronto RUN apk update RUN apk upgrade RUN apk add ...
Alpha's user avatar
  • 151
5 votes

CentOS not considering daylight saving on timezone

Brazil no longer observing DST is in tzdata-2019b circa July. (ICANN, formerly IANA, is the maintainer compiling the changes.) For some reason, I only find 2019a on the CentOS 8 mirrors. Consider ...
John Mahowald's user avatar
5 votes
Accepted

Linux get UTC offset from current (or other) timezones on given date and time

You can use the date command. You set the timezone and then specify the date and time. The command will return that time with the -03 or -04, so you will know if DST was in effect. For example, for ...
Eduardo Trápani's user avatar
4 votes

Docker Container time & timezone (will not reflect changes)

Using a Fedora container (likely to work with ubuntu also): The simplest solution I found was to use the following in docker-compose.yml environment: TZ: "${TZ:-America/Los_Angeles}" ...
Perry Harrington's user avatar
4 votes

Docker Container time & timezone (will not reflect changes)

In alpine basic Image (example use node:10.16.0-alpine): Dockerfile FROM node:10.16.0-alpine ENV TZ=America/Los_Angeles RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ &...
flynn's user avatar
  • 141
4 votes
Accepted

Incorrect Ubuntu server time

Install ntp package sudo apt-get install ntp Edit /etc/ntp.conf for your neighbor ntp server sudo vi +/^server /etc/ntp.conf Reload ntp configuration sudo service ntp reload Check time sync status ...
minish's user avatar
  • 656
4 votes
Accepted

jq sort by date (iso 8601)

You're looking for: jq '.Entities.BackupJobSessions.BackupJobSessions | sort_by(.CreationTimeUTC)' Sorting seems to work as expected, though you could still go with: jq '.Entities.BackupJobSessions....
SYN's user avatar
  • 1,794
4 votes
Accepted

CentOS not considering daylight saving on timezone

Brazil's DST change was included in TZ version 2019b. Running yum update tzdata should get you the newest version (which is actually 2019c, but it includes the change you care about). You can use ...
Moshe Katz's user avatar
  • 3,182
3 votes

execute bash script on last thursday of every month

The way I would tackle this is to run the script using cron every Thursday (day 4 of the week). I would then have my script determine if today was the last Thursday of the month by examining the month ...
user9517's user avatar
  • 116k
3 votes

Portwell motherboard: Boot-time fsck finds "unexpected inconsistency" due to system time

I found the answer to this here: https://unix.stackexchange.com/questions/8409/how-can-i-avoid-run-fsck-manually-messages-while-allowing-experimenting-with-s Apparently, because the system clock is "...
Timothy Miller's user avatar
3 votes

Setting the system date to a day in the past on Windows 2012

I used to work at a place that did this with a training system. (I don't remember which version of Windows it was, but it certainly wasn't 2012--it was 2003 or 2008.) Basically, they had to use ...
Katherine Villyard's user avatar
3 votes
Accepted

Timestamp comparison on AIX without date -d

Perl is probably installed, so you can do timestamp=$( some process ) # timestamp=201607130319 perl -se ' use Time::Local; if ($ts =~ /^(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)$/) { $time = ...
glenn jackman's user avatar
3 votes

Docker Container time & timezone (will not reflect changes)

A more generic way to set the timezone in docker run arguments: -e TZ=`ls -la /etc/localtime | cut -d/ -f8-9` Or for reuse: function GET_TZ () { ls -la /etc/localtime | cut -d/ -f8-9 } ... -e ...
Mugen's user avatar
  • 151
3 votes

Date field is being presented as integer

If I read correctly the ElasticSearch documentation https://www.elastic.co/guide/en/elasticsearch/reference/current/date.html JSON doesn’t have a date datatype, so dates in Elasticsearch can either ...
daks's user avatar
  • 673
3 votes
Accepted

What format are DMARC dates?

There was a converter from DMARC, here it is https://dmarcian.com/dmarc-xml/ And AFAIR there's also converted dates. Correct me if I'm wrong.
Strepsils's user avatar
  • 5,115
3 votes
Accepted

Set date format in nginx autoindex HTML listing

No, it does not seem possible. Based on the source code, the line that seems to generate the date is at https://trac.nginx.org/nginx/browser/nginx/src/http/modules/ngx_http_autoindex_module.c#L630 : ...
Patrick Mevzek's user avatar
3 votes
Accepted

Docker container with random date

Following up on Adrian's comment (which should have been an answer): According the linuxserver FAQ this is a known issue with docker and ubuntu focal images since March 2020. It seems it is related to ...
Filipe Pina's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible