Page 1 of 1

How to best set Centos/Nagios Time?

Posted: Tue Apr 03, 2012 2:57 pm
by jglass
Hello:

Kindly assist me with setting the system time (as I have become very frustrated trying to get it set by myself!). Every time I restart the server my time is slow by 6 hours. I believe I have found the file that is causing this, but I’m not sure about how to fix it. Ultimately, it would be nice to use the system-config-date utility, although this will not run for me.

First, my /etc/localtime file looks funny, and I believe this is the file that is throwing my time off. I’m assuming this since I see the ‘6’ at the bottom on the text, and since my time always shows 6 hours behind. Also, I’m not sure why or if all the foreign characters should be present. Here’s what the file looks like:
GNU nano 2.0.9 File: /etc/localtime

TZif2^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^E^@^@^@^E^@^@^@^@^@^@^@�^@^@^@^E^@^@^@^T��,����p��^N����p��t^N���GpË��Ò#�pÒa �Óu�^@Ô@��ÕUÕ^@ Í� 5�^@Ø^@��Ù^U�^@Ù���Ú���Û�s�ÜÞ�ݩ�p y�ßrp��^@�¿½iTp�~=��I6p�^^_��W<��G<^@�7^^��'^^^@�^W^@��^G^@^@����$
^@^A���^Bw�^@^Cq^Lp^Da^K�^EP�p^F@��^G0�p^G�'� ^P�p ��^@
��p^K���^Lٰ�
�u�^N���^O��^@^P�t�^Q�t^@^RyV�^SiV^@^TY8�^UI8^@^V9^Z�^W)^Z^@^X"7p^Y^H�^@^Z^B^Yp^Z�^X�^[��p^\�ï¿c�) �*�E�+���,Ó³bp-�w�.�Dp/~Y�0�&p1gv^@2s^Hp3GX^@4R�p5':^@62̳p7^G^\^@8^[��8��^@9�ʳ�:Ƴ�^@;ÛO�I�{^@J�1�K���L�NpM|y�N�0pO\[�P�^RpQ<=�Ru�pS^\^_�TU�pT�^A�V5�pV�^^^@X^^��X�^@^@Y����eG=pe�h�g'^_pg�J�i^G^Api�,�j��pk�I^@l���mv+^@n���oV
^@p���q5�^@ro��s^U�^@tO��t���v8�pv�Ïx^X�px���y�hpz���{ØJp|~u�}�,p~^W�^?�^Np^@^A^@N�������Gp����Ë������Ò#�p����Òa �����Óu�^@����Ô@������Õ�^@^@^@^@^@� Í����� 5�^@����Ø^@������Ù^U�^@����Ù�������Ú�����ï^@^@^@^@^@^A���^@^@^@^@^Bw�^@^@^@^@^@^Cq^Lp^@^@^@^@^Da^K�^@^@^@^@^EP�p^@^@^@^@^F@��^@^@^@^@^G0�p^@^@^@^@^G�'�^@��p^@^@^@^@^K���^@^@^@^@^Lٰ�^@^@^@^@
�u�^@^@^@^@^N���^@^@^@^@^O��^@^@^@^@^@^P�t�^@^@^@^@^Q�t^@^@^@^@^@^RyV�^@^@^@^@^SiV^@^@^@^@^@^TY8�^@^@^@^@^UI8c�^@^@^@^@) �^@^@^@^@*�E�^@^@^@^@+���^@^@^@^@,Ó³bp^@^@^@^@-�w�^@^@^@^@.�Dp^@^@^@^@/~Y�^@^@^@^@0�&p^@^@^@^@1gvO�^@^@^@^@I�{^@^@^@^@^@J�1�^@^@^@^@K���^@^@^@^@L�Np^@^@^@^@M|y�^@^@^@^@N�0p^@^@^@^@O\[�^@^@^@^@P�^Rp^@^@^@^@Q��^@^@^@^@eG=p^@^@^@^@e�h�^@^@^@^@g'^_p^@^@^@^@g�J�^@^@^@^@i^G^Ap^@^@^@^@i�,�^@^@^@^@j��p^@^@^@^@k�I^@^@^@^@^@l^@^@^@^@^@p���^@^@^@^@q5�^@^@^@^@^@ro��^@^@^@^@s^U�^@^@^@^@^@tO��^@^@^@^@t���^@^@^@^@v8�p^@^@^@^@v�Ï^@^@^CST6CDT,M3.2.0,M11.1.0��^@^@^@^$

Should I remove everything from this file and leave it with: Zone=”US/Central”

Regarding system-config-date -- I would love to be able to simply use the GUI utility to set the time, but I receive this error:

[root@opsmon ~]# system-config-date
Traceback (most recent call last):
File "/usr/share/system-config-date/system-config-date.py", line 73, in <module>
useGuiMode(page)
File "/usr/share/system-config-date/system-config-date.py", line 46, in useGuiMode
import scdMainWindow
File "/usr/share/system-config-date/scdMainWindow.py", line 30, in <module>
import gtk
File "/usr/lib/python2.6/site-packages/gtk-2.0/gtk/__init__.py", line 64, in <module>
_init()
File "/usr/lib/python2.6/site-packages/gtk-2.0/gtk/__init__.py", line 52, in _init
_gtk.init_check()
RuntimeError: could not open display
[root@opsmon ~]#

Any help would be greatly appreciated!! I am forced to run ntpdate time.nist.gov everytime I need to bring down the system.

I'm running Centos 6.2 with Nagios XI 2011R2.1.

Thanks,

Jason

Re: How to best set Centos/Nagios Time?

Posted: Tue Apr 03, 2012 3:23 pm
by yancy
/etc/localtime is a system binary so I don't think editing it will help.

are you in the correct time zone?

Code: Select all

$ date
Tue Apr  3 15:21:32 CDT 2012
how are you setting the time to the correct time after restarting?

Re: How to best set Centos/Nagios Time?

Posted: Tue Apr 03, 2012 3:54 pm
by jglass
Yes, I am in the right time zone:
# date
Tue Apr 3 15:47:58 CDT 2012

If I were to reboot then the date and time would reset itself. It just clicked, I'm trying to get the date / time to stick, but was only addressing the time zone. I rebooted earlier, and the date set itself to March and the time was 6 hours slow.

I update the date/time by issuing this command:
ntpdate time.nist.gov

So, the question is now, what is the best way to set the time and date?

Thanks,
Jason

Re: How to best set Centos/Nagios Time?

Posted: Tue Apr 03, 2012 4:54 pm
by yancy
I'm not sure what would be setting your time back after each reboot. Maybe something in your startup scripts is causing the time to reset.

One solution would be just to add "ntpdate time.nist.gov" to /etc/rc.d/rc.local

Re: How to best set Centos/Nagios Time?

Posted: Wed Apr 04, 2012 2:24 pm
by jglass
Thanks for the tip, Yancy. That worked.

-Jason