# Receiving mail through Sendmail wrong time



## dpalme (Apr 30, 2015)

For some reason when we upgraded our box our time zone got out of wack. 

I did the following:

`cp /usr/share/zoneinfo/America/Chicago /etc/localtime`

When I enter

`date`

I get the following:


```
Thu Apr 30 10:57:12 CDT 2015
```

so it appears to be set correctly, but when I get mail its showing 5 hours LATER....

I'm not sure where to go from here to fix this, but any help would be appreciated.


----------



## kpa (Apr 30, 2015)

Is the hardware clock in UTC or local time and have you run tzsetup(8) after the upgrade?


----------



## dpalme (Apr 30, 2015)

Never thought of that, but that did the trick.

Thanks Kpa.


----------



## dpalme (May 7, 2015)

Something is still wrong, I haven't quite figured out yet, but after setting the `tzsetup` and verifying that the hardware is set for CDT, it seems that sometime overnight the time moves itself up by 6 hours...

So as an example, I just sent myself a test message this morning where it is currently 8:27am, but the email shows a receipt time of 1:27pm.

If I go back and reset the tzsetup it will correct it, so I'm not sure if another process is changing it or if a reboot is playing havoc with me.

Suggestions?


----------



## wblock@ (May 7, 2015)

CDT is UTC - 6 hours.  Does /etc/wall_cmos_clock exist?


----------



## dpalme (May 7, 2015)

Yes but it appears to be blank.


----------



## kpa (May 8, 2015)

dpalme said:


> Yes but it appears to be blank.



That's normal, the file is only a "flag" file for testing if a setting is on or off, from adjkerntz(8):


```
If the file /etc/wall_cmos_clock exists, it means
that the CMOS clock keeps local time (MS-DOS and MS-Windows compatible
mode).  If that file does not exist, it means that the CMOS clock keeps
UTC time.  The adjkerntz utility passes this state to the
machdep.wall_cmos_clock kernel variable.
```

This is what gets run by cron(8) every night and might be the culprit in your case, from /etc/crontab:


```
# Adjust the time zone if the CMOS clock keeps local time, as opposed to
# UTC time.  See adjkerntz(8) for details.
1,31    0-5     *       *       *       root    adjkerntz -a
```

Try running that manually during the day and see if you can replicate the problem.

I would switch to running the HW clock in UTC if that's possible, it's a much less complicated and error-prone setup anyway.


----------



## dpalme (May 12, 2015)

Yep that's in the /etc/crontab

So if I set the hw to UTC that should resolve the issue correct?


----------



## kpa (May 12, 2015)

dpalme said:


> Yep that's in the /etc/crontab
> 
> So if I set the hw to UTC that should resolve the issue correct?



It should work both ways and I have no idea why it doesn't work for you with HW clock in local time. Set the HW clock to UTC, run tzsetup(8) again with the UTC option selected and see how it goes.

Setting the HW clock to UTC makes configuration easier because the kernel runs in UTC internally anyway. All UNIX and UNIX-like OSes prefer to have the HW clock set to UTC.


----------



## dpalme (May 12, 2015)

Reset the HW clock and restarted the server, now it seems to be reporting the time correctly.

I'll see what it does tomorrow....


----------



## dpalme (May 18, 2015)

That fixed it, I gave it a few days to make sure it was in fact fixed.


----------

