Servers with same timezone but different time - linux

I have 3 servers, 2 on AWS and one on Digital Ocean, and the timezone for all is set to CDT. But when I check the current time on all 3 by using the date command via command line, none of them matches.
Server1: Wed Jun 12 23:36:01 CDT 2019
Server2: Wed Jun 12 23:45:51 CDT 2019
Server3: Wed Jun 12 23:38:39 CDT 2019
Could anyone please suggest what needs to be done here? Thanks.

Since you have not explicitly said that you have ntp running on them, you'll need to install that. Once that is installed and set up properly, you should show the same exact time on all of them.

Related

Silence sysstat-collect.service?

The sar tool collects load values every 10 minutes on my CentOS Linux release 8.5.2111
via the service sysstat-collect.service. It fills /var/log/messages with:
Dec 26 12:50:04 node systemd[1]: Starting system activity accounting tool...
Dec 26 12:50:04 node systemd[1]: sysstat-collect.service: Succeeded.
Dec 26 12:50:04 node systemd[1]: Started system activity accounting tool
Every 10 minutes. That's annoying, I want to silence it. Is it possible??
Thanks in advance
You can use logrotate to select what logs you want to keep or delete

Node.js Date does not consider DST (daylight saving time)

I'm living in Vancouver, west coast of North America, Canada. The original timezone here is PST (pacific standard time, UTC - 8h), but it's now PDT (pacific daylight time, UTC - 7h) since the daylight saving time has started.
The problem is that Node.js uses the original non-DST time, while Ubuntu returns DST.
In the following, both should be 21:44.
$ echo `date` , `node -e "console.log(new Date().toString())"`
Mon May 25 21:44:57 DST 2020 , Mon May 25 2020 20:44:57 GMT-0800 (GMT-08:00)
Why does this happen? How to let Node.js recognize DST?
I use Noce.js v12.16.3 on Ubuntu 18.04.4 as WSL on Windows 10. (Node.js v12.16.3 for Windows works correctly.) TZ env is not set.
UPDATE I don't want to install external libraries.
A more accurate library would be moment.js. You can set the time to recognize DST like this:
moment(timestamp).tz(timezone).isDST()
Here is an example:
moment(1451624400000).tz('America/New_York').isDST();
You can read more about recognized timestamps and timezones in the documentation on the website that I linked above.
My test shows that node does honor daylight saving time:
$ date; node -e "console.log(new Date().toString())";
Fri Jul 17 23:13:32 EDT 2020
Fri Jul 17 2020 23:13:32 GMT-0400 (Eastern Daylight Time)
$ date --date='Fri Jul 17 2020 23:13:32 GMT-0400'
Fri Jul 17 23:13:32 EDT 2020
$ node -v
v10.21.0
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04 LTS
Release: 20.04
Codename: focal

Setting linux time properly (UTC)

I have problems with the time settings on my linux server. The timezone is set to UTC, the locale settings are the following: (locale -a)
C
C.UTF-8
en_GB.utf8
POSIX
date command gives me
Wed Jul 26 09:39:42 UTC 2017
but the correct time is 10:39
On my desktop I have the same locale settings and utc timezone and it gives me the correct time.
Could someone explain what's wrong with the server and what should be changed, please?
Thanks in advance.

Long MAC addres in Cisco DHCP binding

i have problem whith Cisco DHCP. On switch C6506 in "sh ip dhcp binding" table are the long MAC addres. What is the problem? The one MAC (00.16e6.448a.e4) have more IP addres.
158.195.40.46 id ffe6.448a.e400.0100.011d.69e6.3900.16e6.448a.e4 Mar 12 2016 03:35 PM
158.195.46.201 id ffe6.448a.e400.0100.011d.d88f.c400.16e6.448a.e4 Mar 12 2016 12:10 PM
158.195.46.202 id 0100.16e6.448a.e4 Mar 12 2016 02:09 PM
158.195.46.203 id ffe6.448a.e400.0100.011d.d8b0.1b00.16e6.448a.e4 Mar 12 2016 02:28 PM
158.195.46.204 id ffe6.448a.e400.0100.011d.d8b2.0500.16e6.448a.e4 Mar 14 2016 09:53 PM
Answer is here: https://supportforums.cisco.com/discussion/12708241/weird-mac-address-dhcp-binding
"Okay. Please check the file /etc/dhcp/dhclient.conf on the Fedora machine and add the following line to the file:
send dhcp-client-identifier = hardware;
If there are any other instances of this command in that file, please remove them - make sure this is the only one."

Change system date time in Docker containers without impacting host

Is it possible to change the system time in Docker containers without changing the host itself?
We are using Docker containers for testing which are sometimes time sensitive. I notice that any changes made to the host time are reflected to the Docker containers right away (which makes sense since they are using the same kernel). I am hoping, however, that Docker provides a way for you to somehow override the start time of the container and move from thereon.
Just a follow up for those looking to have different datetime in Docker containers, https://github.com/wolfcw/libfaketime should probably be able to do the job.
Simple:
Steps:
First check the localtime of the docker container:
[root#locdb oracle]# zdump /etc/localtime
/etc/localtime Tue May 22 13:59:40 2018 UTC
Check the timezones like below:
[root#locdb oracle]# zdump /usr/share/zoneinfo/* | tail -10
/usr/share/zoneinfo/UTC Tue May 22 14:01:21 2018 UTC
/usr/share/zoneinfo/Universal Tue May 22 14:01:21 2018 UTC
/usr/share/zoneinfo/W-SU Tue May 22 17:01:21 2018 MSK
/usr/share/zoneinfo/WET Tue May 22 15:01:21 2018 WEST
/usr/share/zoneinfo/Zulu Tue May 22 14:01:21 2018 UTC
/usr/share/zoneinfo/iso3166.tab Tue May 22 14:01:21 2018
/usr/share/zoneinfo/posix Tue May 22 14:01:21 2018
/usr/share/zoneinfo/posixrules Tue May 22 10:01:21 2018 EDT
/usr/share/zoneinfo/right Tue May 22 14:01:21 2018
/usr/share/zoneinfo/zone.tab Tue May 22 14:01:21 2018
Copy the one that you need for example :
cp /usr/share/zoneinfo/UTC /etc/localtime
As described in detail here the solution that I follow is to run docker on top of a VM and automate the whole process of changing-vm-time, running-vm and running-container, via vagrant.

Resources