![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Tips and Tutorials Helpful articles from our Users. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Understanding this Makefile | the_learner | High Level Programming | 5 | 06-13-2007 10:55 PM |
| Need Help Understanding a Unix Command | chris86 | UNIX for Dummies Questions & Answers | 6 | 10-10-2006 12:35 PM |
| A little help understanding FIFOs? | deckard | Linux | 0 | 11-01-2005 09:46 AM |
| need further understanding of init.d | jigarlakhani | UNIX for Advanced & Expert Users | 1 | 09-20-2002 12:11 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
| Forum Sponsor | ||
|
|
|
||||
|
Daylight Saving Ruled Have Changed And I have No Patch....What To Do?
Let's say my system is still set up for last year's rule. My system will soon show the wrong time. What should I do? One thing that is not a very good idea would be to crank the clock forward an hour manually. If I do that my system will have the wrong internal time. Some network based services such as NFS use the internal time. My system would also no longer have the correct Universal Time. NTP (Network Time Protocol) will malfunction and my system's clock will drift. Even for my own timezone, I would have timestamps like 17:00 EST when I should have 17:00 EDT. A few weeks later, the old rule will take effect and I will now need to adjust the clock manually again.
I hope that I have convinced you to not reset the time in this manner. One better option would be to research my system's data file that defines the daylight saving rules for my timezone and edit it myself. This should be a straight forward change. But each system may have its own format. There does seem to be a near universal solution: use a more complex format for the TZ environment variable. You can actually put the Daylight Saving rule in TZ and this behavior is mandated by Posix. Below is a table of TZ settings that I believe to be correct for the year 2007. Code:
# Posix Format TZ="EST5EDT4,M3.2.0/02:00:00,M11.1.0/02:00:00" # US Eastern TZ="CST6CDT5,M3.2.0/02:00:00,M11.1.0/02:00:00" # US Central TZ="MST7MDT6,M3.2.0/02:00:00,M11.1.0/02:00:00" # US Mountain TZ="PST8PDT7,M3.2.0/02:00:00,M11.1.0/02:00:00" # US Pacific TZ="AST9ADT8,M3.2.0/02:00:00,M11.1.0/02:00:00" # US Alaska TZ="HST10" # US Hawaii # Old System V Release 3.1 and Xenix Format TZ="EST5EDT4;M3.2.0/02:00:00,M11.1.0/02:00:00" # US Eastern TZ="CST6CDT5;M3.2.0/02:00:00,M11.1.0/02:00:00" # US Central TZ="MST7MDT6;M3.2.0/02:00:00,M11.1.0/02:00:00" # US Mountain TZ="PST8PDT7;M3.2.0/02:00:00,M11.1.0/02:00:00" # US Pacific TZ="AST9ADT8;M3.2.0/02:00:00,M11.1.0/02:00:00" # US Alaska TZ="HST10" # US Hawaii |
|
||||
|
Special Considerations For cron
cron Will Respond To Changes in Time
If you adjust the system time while cron is running, cron will notice and attempt to compensate. If time moved backwards, cron will stop running jobs and wait for the clock to advance back to where cron run the last job. If time moved forwards, cron will try to catch up. It will click though each minute continuously until it has run all of the jobs scheduled during the skipped time duration. If you are simply tweaking the system clock because it was off a few seconds, this is perfect. But if the time is a year off, it will probably not be a good thing. For large adjustments to the clock you should kill and restart cron. cron Will Respond To Daylight Saving Changes Suppose I have a job scheduled to run at 2:15 Sunday morning. When we "spring ahead", there won't be a 2:15. cron will note that we "sprung ahead" by 60 minutes, so it will add 60 minutes to my job time getting 3:15. It will run the job at 3:15...unless the job was already scheduled to run at both 2:15 and 3:15. In that case, my job will run once at 3:15. Later in the year, we "fall back". On that Sunday, it will be 2:15 twice. My job will only run at the first 2:15. If my job is scheduled to run at 15 minutes after every hour via the explicit use of an asterisk in the hour field my job will run at both 2:15's. This is not true if I use a range or a list of hours to run. Only jobs with an asterisk for the hour field run at both 2:15's. cron Has Its Own Timezone If I schedule my job for 2:15 in the morning, cron will run it when it thinks that the time is 2:15. cron is closely related to the "at" command. If I schedule at job via "at" to run at 2:15, my TZ variable is inspected and the job will run at my 2:15. But cron does not work that way. |
|
||||
|
Leap Seconds
The definition of a second is carefully fixed. Each second is exactly as long as any other second. When scientists were tying down the precise value of a second, they matched it as exactly as possible to the year 1900. There are 24*60*60=86400 seconds in a day. But the Earth has slowed down a bit mostly due to tidal forces. Every year it needs about .7 seconds extra. Every now and then we have a day with 86401 seconds. Unix tries to pretend that this is not the case. If you are not running NTP, then you must periodically manually tweak your clock and you will compensate for a leap second during your next manual adjustment.
If you are running NTP, Unix tries to make the last second of the day with a leap second last for 2 seconds. With many implementations, the second will inappropriately advance in the middle of this special long second and will be adjusted backwards a few milliseconds later. So ignoring the potential messy second-long transition, we treat each day as if it was 86400 seconds long. By the way, it took about a century for the Earth to slow down enough to need .7 seconds extra each year. It will take another century for to slow down enough to need about 1.4 seconds extra year. Do not think that each year is .7 seconds longer than its immediate predecessor. |
|
||||
|
My Perl script
Here is my Perl script that I used in this article...
Code:
#! /usr/local/bin/perl
sub printtime($)
{
@d=localtime $_[0];
printf "%12d %3s %4d-%02d-%02d %02d:%02d:%02d %s\n", $_[0],
(Sun,Mon,Tue,Wed,Thu,Fri,Sat)[$d[6]],
$d[5]+1900,$d[4]+1,$d[3],$d[2],$d[1],$d[0],
("Standard Time","Daylight Saving Time")[$d[8]];
}
while (do {print "Enter val - "; chomp($val = <>)}) {
print "val = ", $val, "\n";
printtime $val;
printtime $val+1;
}
print "\n";
|
|
||||
|
Miscellaneous Odds and Ends
Your OS Imposes Limits On The Range of Dates That It Can Format
You need to check the documentation for your system to which dates it can handle. For example, HP-UX 11i Version 2 says: The minimum date supported by mktime() in both 32-bit and 64-bit HP-UX is Friday December 13 20:45:52 UTC 1901. The maximum dates supported by mktime() are Tuesday January 19 03:14:07 UTC 2038 and Friday December 31 23:59:59 UTC 9999 in 32-bit HP-UX and 64-bit HP-UX, respectively. If the calendar time cannot be represented, the function returns the value (time_t)—1 and sets errno to ERANGE. Note the value (time_t)—1 also corresponds to the time 23:59:59 on Dec 31, 1969 (plus or minus time zone and Daylight Saving Time adjustments). Thus it is necessary to check both the return value and errno to reliably detect an error condition. Solaris 10 says: The zoneinfo timezone data files do not transition past Tue Jan 19 03:14:07 2038 UTC. Therefore for 64-bit applications using zoneinfo timezones, calculations beyond this date might not use the correct offset from standard time, and could return incorrect values. This affects the 64-bit version of localtime(), localtime_r(), ctime(), and ctime_r(). Nanosecond Resolution I notice that Posix is specifying a variety of nanaosecond resolution routines. I see that Solaris 10 has implemented them. I have no experience with them and I have ignored them for this thread. The clock_settime(3RT) man page says: Quote:
If you display the time in nanoseconds, be sure to keep your eyes very close to the screen. Light cannot travel even a full foot in a nanosecond. Further Reading Be sure to read mtime, ctime, and atime for information about the timestamps of files. |
||||
| Google The UNIX and Linux Forums |
| Tags |
| clock, mtime, timekeeping |
| Thread Tools | |
| Display Modes | |
|
|