Time zone mismatch calling date via ssh - linux

I'm getting two different timezones on Linux (CENTOS 5.6) depending on whether date is called locally or via ssh:
foo$ ssh me#bar date
Tue Nov 5 18:08:32 EST 2013
foo$ ssh me#bar
bar$ date
Tue Nov 5 17:09:16 CST 2013
/etc/localtime is set to central time:
$ ls -l /etc/localtime
lrwxrwxrwx 1 root root 27 Nov 5 13:10 /etc/localtime -> /usr/share/zoneinfo/CST6CDT
TZ is set to America/Chicago in .bash_profile. If that line is commented out, time zone comes back as eastern rather than central.
I'm assuming this all means the computer believes in its heart that it's on eastern rather than central time and the TZ setting in the shell just overrides this, but I can't figure out WHY the computer thinks it's in eastern time.
edit
It turned out that a runaway process somewhere had actually overwritten the central time timezone file with an eastern time timezone file. Not easy to find, as the file contents are binary!

Did you check -> /etc/sysconfig/clock ?

Related

Time difference issue of container and host

I am running container in a Linux VM, the "date" command on VM gives the right time back, while in containers, "date" returns the same result as date on VM. What is different is that when I touch a file in container, and then ls -l this file, the time created is not the same as date in container returned. I tried the same steps on a Centos VM using docker, the date and container file time is the same. Below are the details, could anyone tells me what is the difference?
In VM:
date returns: Fri Jan 10 15:55:37 UTC 2020
In Container:
date returns: Fri Jan 10 15:55:40 UTC 2020
then "touch aaaa" and ls -l aaaa returns: Jan 10 08:03 aaaa
The issue is date in container should returns the Jan 10 08:03, not the VM time.
Is there anything I missed while running a container?
Thanks!

Time not set right, date -u and hwclock -u yield different results

so i am having this weird problem with my clock on pc. I am currently using Kali Linux 2018.1.
Basically my problem is that my computer time is one hour behind every time i start my pc. So is my hardware clock. What i find even weirder is that date -u and hwclock -u display different results:
root#horse:/etc# date
Sat Mar 3 22:50:56 CET 2018
root#horse:/etc# hwclock
2018-03-03 22:50:59.654599+0100
root#horse:/etc# date -u
Sat Mar 3 21:51:03 UTC 2018
root#horse:/etc# hwclock -u
2018-03-03 23:51:09.904595+0100
root#horse:/etc#
The time from hwclock -u is the correct one.
Can you please help me understand and solve this issue?
Since hwclock -u showed the correct time:
#hwclock -u > date -s
#hwclock -w
This seemed to do the trick.
Alternatively :
#date -s M/D/Y +hh:mm
#hwclock -w

last command in linux shows `:0` in 3rd column, what does it mean?

I want to write a shell script sort out the data that last command shows.
I got this in my server.
root pts/0 10.168.136.175 Wed Sep 14 14:24 - 14:54 (00:29)
root :0 Mon Sep 12 10:34 - 11:00 (00:25)
reboot system boot 2.6.18-308.el5PA Sun Sep 11 11:31 (86+03:05)
I did some search, there are some saying :0.0 in the 3rd column means login locally, second column means what kind of terminal been use, like pts and tty.
But what does the :0 in line 2 second column in my log?
I am using redhat 6.5.
It means local computer. Generally each session represented by pairs ip_address:display_number. When you logged in locally the IP address is omitted. That's why there is nothing before :. Display number is actually the session number from the specified IP address. So, 0 means the first session

Different date format in UNIX and Linux server

I am migrating all my script from UNIX server to Linux server, but both the server have different date format.
How I can make both format same ?
UNIX:
bash-3.2$ date
Tuesday, 25 October 2016 15:57:04 BST
LINUX:
[ess#gmessd04 ~]$ date
Tue 25 Oct 16:01:20 BST 2016
Unix server version : SunOS 5.10
Linux server version : Linux 3.10
Thanks,
Shadab Hussain
You could use the parameter of the date command to get the same result on linux you have on unix.
$date "+%A, %d %B %k:%M:%S %Z"
For more info about the date modifier see manpage of date command:
$man date
If you need like to change the output of date without typing the parameter all the time, you could set it as alias:
$alias date='date "+%A, %d %B %k:%M:%S %Z"'

cron command runs but does not know the date or time

Perhaps I'm just missing something simple so here goes.
I have a webmin server on Ubuntu and also OpenGTS on a vps, everything works fine and I set it all up from scratch.
I have a cron job like this:
bash /usr/local/OpenGTS_2.5.0/bin/trim.sh
trim.sh is:
#!/bin/sh
MAILTO=me#mymail.net
cd /usr/local/OpenGTS_2.5.0/bin/
./admin.sh Device -account=vehicles -device=laguna -deleteOldEvents=-5d -confirmDelete
This should delete old entries from the database older than 5 days
When run from command line it outputs correctly
Entry Point: org.opengts.db.tables.Device
Deleting events before "Wed Jun 11 23:59:59 BST 2014" ...
Device: laguna - Deleted 0 old events (Saved last event, Nothing to delete)
However when it runs from cron
Entry Point: org.opengts.db.tables.Device
Deleting events before "Mon Jun 09 23:59:59 BST 2014" ...
Device: laguna - Deleted 0 old events (Empty range)
If I set it to 1 day, or 2 days it still insists on Mon Jun 09 23:59:59 BST 2014
I'm totally stumped, any ideas ?
thanks

Resources