####### # # E-scripts on clock, hwclock, NTP.... # # Note 1: use the eev command (defined in eev.el) and the # ee alias (in my .zshrc) to execute parts of this file. # Executing this file as a whole makes no sense. # # Note 2: be VERY careful and make sure you understand what # you're doing. # # Note 3: If you use a shell other than zsh things like |& # and the for loops may not work. # # Note 4: I always run as root. # # Note 5: some parts are too old and don't work anymore. Some # never worked. # # Note 6: the definitions for the find-xxxfile commands are on my # .emacs. # # Note 7: if you see a strange command check my .zshrc -- it may # be defined there as a function or an alias. # # Note 8: the sections without dates are always older than the # sections with dates. # # This file is at # or at . # See also , # , # , # , # and . # ####### # «.zone_differences» (to "zone_differences") # «.timezones» (to "timezones") # «.ntpdate» (to "ntpdate") # «.ntpdate-adj» (to "ntpdate-adj") # «.setting-DST-by-hand» (to "setting-DST-by-hand") ##### # # clock # 2000may28 # ##### # «clock» # (eeman "8 hwclock") # (find-fline "/etc/init.d/hwclock.sh") # (find-status "util-linux") # (find-vldifile "util-linux.list") # (find-fline "/usr/doc/util-linux/") # (find-fline "/usr/doc/util-linux/README.Debian.hwclock.gz") # (find-saghw3 "book1.html" "clock") # (find-fline "/etc/" "localtime") ######## # # date/hwclock # 99nov13 # ######## # «clock0» # (find-node "(sh-utils)date invocation") # (find-node "(sh-utils)Options for date") # (find-node "(sh-utils)Time directives") # (find-node "(sh-utils)Date directives") # (find-node "(sh-utils)Examples of date") # (find-node "(sh-utils)Calendar date items") # (find-node "(sh-utils)General date syntax") # (find-node "(sh-utils)Time of day items") # (find-node "(sh-utils)Time zone items") # # Like 1999Jan07: date +%Y%b%d date +%Y%b%d | tr A-Z a-z date +'%Y%b%d %-l:%M %Z (%z)' date --utc +'%Y%b%d %-l:%M %Z (%z)' date --set='1999jan08 22:51' date +'%Y%b%d %-l:%M %Z (%z)' date --utc +'%Y%b%d %-l:%M %Z (%z)' date --set='Jan 7 21:02:35 EDT 1999' date --set='-2 hours' date --set='EDT' date --set='Jan 8 0:03:38 1999' date hwclock --hctosys date # hwclock --systohc hwclock --show hwclock --utc --set --date='13 Nov 1999 19:32 EDT' hwclock --set --date='13 Nov 1999 19:32 EDT' cat /proc/rtc ;echo hwclock --show ;echo hwclock --utc --show ;echo TZ=EDT hwclock --utc --show ;echo TZ=EDT hwclock --show ;echo date -d '13 Nov 1999 19:10 EDT' date -d '13 Nov 1999 19:10:25' date -d '13 Nov 1999' date -d '19:10' date -d '19:10:25' date -d '19:10:25 EDT' rm -Rv /usr/src/util-linux-2.9g/ pdsc /big/slinks1/dists/slink/main/source/base/util-linux_2.9g-6.dsc cd /usr/src/util-linux-2.9g/ # # (code-c-d "utill" "/usr/src/util-linux-2.9g/") # (find-utillfile "") # (find-utillfile "sys-utils/hwclock.c") # (find-utillfile "sys-utils/hwclock.c" "interpret the date string") # Lixos: hwclock --systohc --utc --test --debug hwclock --systohc --test --debug hwclock --utc --systohc hwclock --utc --show hwclock --utc --hctosys date hwclock --hctosys ##### # # Difference between local time and GMT/UTC # 2000jul11 # ##### # «zone_differences» (to ".zone_differences") # (find-status "libc6") # (find-vldifile "libc6.list") # (find-fline "/usr/doc/libc6/") # (find-fline "/usr/bin/822-date") # (find-man "perlfunc" "localtime EXPR") # (find-node "(libc)Calendar Time") # (find-node "(libc)TZ Variable") # (find-node "(libc)TZ Variable" "EST+5") # (find-fline "/usr/share/zoneinfo/") # (find-fline "/usr/share/zoneinfo/iso3166.tab" "alpha-2 country codes") # (find-fline "/usr/share/zoneinfo/zone.tab") # (find-man "1 zdump") # (find-man "8 zic") # (find-man "1 822-date") # (find-sh "cd /usr/share/zoneinfo/; zdump Brazil/* America/Sao_Paulo not-a-zone") # (find-sh "cd /usr/share/zoneinfo/; zdump -v America/Sao_Paulo not-a-zone") # echo "2\n9\n6\n1" | /usr/bin/tzselect |& tee ~/o grep 'is now' ~/o # cd /usr/share/zoneinfo/ zdump Brazil/* America/New_York America/Sao_Paulo America/Mexico_City \ America/Montreal *T* Universal Greenwich posix* not-a-zone foo-bar TZ=GMT 822-date TZ=BRT 822-date TZ=BRST 822-date TZ=foo 822-date TZ=Brazil/East 822-date TZ=America/Mexico_City 822-date TZ=America/Montreal 822-date # # (find-sh0 "TZ=GMT 822-date") # (find-sh0 "TZ=BRT 822-date") # (find-sh0 "TZ=BRST 822-date") ##### # # more on timezones # 2003jan23 # ##### # «timezones» (to ".timezones") # A great way (it seems) to discover the date is to set the clock to: # (find-node "(sh-utils)Time zone items") # (find-node "(sh-utils)Time zone items" "DST") # (find-node "(sh-utils)Options for date" "`-f DATEFILE'") # (find-node "(sh-utils)Options for date" "`-d DATESTR'") # (find-node "(libc)TZ Variable") # (find-node "(libc)TZ Variable" "`TZ=:/etc/localtime'") # (find-node "(libc)TZ Variable" "`/share/lib/zoneinfo/CHARACTERS'") # (find-fline "/usr/share/zoneinfo/") date -d '12:00 EDT 7 feb 1990' date -d '12:00 EDT 7 feb 1990' | TZ=EDT date -f - ;echo date -d '12:00 EDT 7 feb 1990' | TZ=EST date -f - ;echo date -d '12:00 EDT 7 feb 1990' | TZ='EST DST' date -f - ;echo date -d '12:00 EDT 7 feb 1990' | TZ=UTC date -f - ;echo # date -d '12:00 UTC 11 may 2001' D=$(TZ=UTC date -d '12:00 UTC 11 may 2001') echo $D for i in EDT EST 'EST DST' 'GMT-4' 'UT-4' foo \ America/Sao_Paulo EST5EDT; do D2=$(TZ=$i date -d $D) echo $D '->' $D2 " ($i)" done | sort # Non-existing time zones will keep the same time as UTC # # (find-man "tzsetup") # (find-man "tzsetup" "UTC=yes") # (find-fline "/etc/default/rcS" "UTC=") tzsetup laf /usr/share/zoneinfo/localtime laf /etc/localtime # I'm using (tentatively) EST when I'm not in daylight savings, # EST5EDT when daylight saving are on (I live in Rio de Janeiro, btw). # (find-fline "/usr/share/zoneinfo/SystemV/" "EST5EDT") # (find-man "8 hwclock") # (find-htetfile "mini/Clock.gz") # (find-htetfile "mini/Clock.gz" "/usr/share/zoneinfo") # (find-man "tzselect") # (find-fline "/usr/bin/tzselect") # (find-fline "/usr/bin/tzselect" "TZ_COUNTRY_TABLE=") # (find-fline "/usr/share/zoneinfo/") # (find-fline "/usr/share/zoneinfo/iso3166.tab") # (find-fline "/usr/share/zoneinfo/iso3166.tab" "TP\tEast Timor") # (find-fline "/usr/share/zoneinfo/zone.tab") # (find-fline "/usr/share/zoneinfo/zone.tab" "America/Sao_Paulo") # (find-fline "/usr/share/zoneinfo/") # (find-fline "/usr/share/zoneinfo/America/") # (find-fline "/usr/share/zoneinfo/America/" "Sao_Paulo") # (find-fline "/usr/include/linux/time.h") # (find-fline "/usr/include/time.h") ##### # # ntpdate # 2004mar03 # ##### # «ntpdate» (to ".ntpdate") # (find-status "ntpdate") # (find-vldifile "ntpdate.list") # (find-udfile "ntpdate/") # (find-man "1 ntpdate") # (find-udfile "ntpdate/README.Debian") # (find-udfile "ntpdate/README.Debian" "editing /etc/init.d/ntpdate") # (find-fline "/etc/init.d/ntpdate") # (find-fline "/etc/default/ntpdate")  (eepitch-shell)  (eepitch-kill)  (eepitch-shell) R sudo update-rc.d ntpdate remove sudo update-rc.d -f ntpdate remove sudo /etc/init.d/ntpdate start # (find-status "ntp-simple") # (find-vldifile "ntp-simple.list") # (find-vldifile "ntp-simple.list" "/usr/sbin/ntpd") # (find-vldifile "" "ntp-simple.list") # (find-fline "/usr/doc/ntp-simple/") # (find-vldifile "ntp-simple.config") # (find-vldifile "ntp-simple.postinst") # (find-fline "/etc/ntp.conf") # # (find-fline "/etc/default/ntp-servers") dpkg-reconfigure ntp-simple # # (find-fline "/etc/init.d/ntp") # (find-man "1 ntpd") /etc/init.d/ntp stop netstat -l | tee ~/onl # (find-status "ntp-doc") # (find-vldifile "ntp-doc.list") # (find-fline "/usr/doc/ntp-doc/") # (find-fline "/usr/doc/ntp-doc/html/hints/") # (w3m "/usr/doc/ntp-doc/html/index.htm") # (w3m "/usr/doc/ntp-doc/html/ntpdate.htm") # (w3m "/usr/doc/ntp-doc/html/ntpd.htm") # (w3m "/usr/doc/ntp-doc/html/ntpdc.htm") # (w3m "/usr/doc/ntp-doc/html/ntpq.htm") # (find-w3m "/usr/doc/ntp-doc/html/ntpd.htm" "\n-g") # (find-w3m "/usr/doc/ntp-doc/html/ntpd.htm" "\n-l logfile\n") # (find-w3m "/usr/doc/ntp-doc/html/ntpd.htm" "\n-q") # (find-w3m "/usr/doc/ntp-doc/html/ntpd.htm" "\n-v") # (find-w3m "/usr/doc/ntp-doc/html/ntpd.htm" "ntpdate") # (find-w3m "/usr/doc/ntp-doc/html/ntpd.htm" "iburst") # (find-w3m "/usr/doc/ntp-doc/html/ntpd.htm" "iburst" "iburst") # (find-w3m "/usr/doc/ntp-doc/html/confopt.htm" "\n iburst\n") # (find-w3m "/usr/doc/ntp-doc/html/assoc.htm" "iburst") # date date -s 12:00 date # cat /etc/ntp.conf \ | awk '{if ($1=="server") {print $0,"iburst"} else print}' \ > /tmp/ntp.conf.iburst diff /etc/ntp.conf /tmp/ntp.conf.iburst # (find-fline "/etc/ntp.conf") # (find-fline "/tmp/ntp.conf.iburst") ntpd -c /tmp/ntp.conf.iburst -g -l /proc/self/fd/0 -q # # (find-man "8 hwclock" " --systohc") hwclock --systohc psne http://www.dicas-l.unicamp.br/dicas-l/20010817.shtml psne http://www.eecis.udel.edu/~mills/ntp/clock2a.html # (eev "lynx $S/http/www.eecis.udel.edu/~mills/ntp/clock2a.html") # (eev "lynx $S/http/www.dicas-l.unicamp.br/dicas-l/20010817.shtml") # (w3m "/home/edrx/snarf/http/www.eecis.udel.edu/~mills/ntp/clock2a.html") # (w3m "/home/edrx/snarf/http/www.dicas-l.unicamp.br/dicas-l/20010817.shtml") # NTPSERVERS=( ntp.hiway.com.br ntp.pop-pr.rnp.br ntp.ufes.br ) ntpdate -v -v $NTPSERVERS # clock-1.cs.cmu.edu fuzz.psc.edu ns.nts.umn.edu ntp-0.cso.uiuc.edu ntp-1.cede.psu.edu ntp-1.ece.cmu.edu ntp-1.mcs.anl.gov ntp-1.vt.edu ntp.hiway.com.br ntp.pop-pr.rnp.br # (find-fline "/etc/services" "\nntp\t") netstat -l Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name udp 0 0 200.214.105.189:123 0.0.0.0:* 625/ntpd udp 0 0 127.0.0.1:123 0.0.0.0:* 625/ntpd udp 0 0 0.0.0.0:123 0.0.0.0:* 625/ntpd Active UNIX domain sockets (servers and established) Proto RefCnt Flags Type State I-Node PID/Program name Path unix 2 [ ] DGRAM 1809 626/ntpd unix 2 [ ] DGRAM 1802 625/ntpd # (find-status "libc6") # (find-vldifile "libc6.list" "/usr/share/zoneinfo/America/") # (find-fline "/usr/bin/tzselect") # (find-fline "/usr/sbin/tzconfig") # BRT # (find-status "ntpdate") # (find-vldifile "ntpdate.list") # (find-vldifile "" "ntpdate.list") # (find-fline "/usr/doc/ntpdate/") # (find-fline "/etc/init.d/ntpdate") # (find-man "1 ntpdate") # (find-status "ntp") # (find-vldifile "ntp.list") # (find-fline "/usr/doc/ntp/") # (find-fline "/usr/doc/ntp/README.Debian.gz" "hwclock --systohc") # (find-man "1 ntpsweep") ##### # # chrony # 2004mar03 # ##### # (find-available "chrony") # (find-available "adjtimex") # (find-progoutput "grep-available -i ntp | grep-dctrl -v -i nntp") # (find-available "ntpdate") # (find-htetfile "Clock.gz") # (find-man "1 zdump") # (find-man "8 zic") # http://enigma.nobel.com.br/tmp/Sao_Paulo # rm -Rv /tmp/tz/ mkdir /tmp/tz/ cd /tmp/tz/ cp -v $S/http/enigma.nobel.com.br/tmp/Sao_Paulo . cat > sample <<'%%%' # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule US 1967 1973 - Apr lastSun 2:00 1:00 D # Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL] Zone Australia/Adelaide 9:30 Aus CST 1971 Oct 31 2:00 %%% zic -d /tmp/tz/zones < sample # ##### # # the easy way to make ntpdate adjust the time in a debian system # 2005jan10 # ##### # «ntpdate-adj» (to ".ntpdate-adj") # (find-status "ntpdate") # (find-vldifile "ntpdate.list") # (find-udfile "ntpdate/") # (find-status "ntpdate" "machines that are not on the net full-time") # (find-fline "/etc/init.d/ntpdate") # sudo /etc/init.d/ntpdate reload # # My guess is that for machines on dial-up we should remove ntpdate # from the initialization scripts, # # (find-vldifile "ntpdate.postinst" "update-rc.d ntpdate start 51 S .") # # and run "sudo /etc/init.d/ntpdate reload" by hand from time to time # when we're connected (or add it to ppp-up or whatever). # # Etch: # (find-status "ntpdate") # (find-vldifile "ntpdate.list") # (find-udfile "ntpdate/") # (find-fline "/etc/network/if-up.d/ntpdate") # (find-fline "/usr/sbin/ntpdate-debian") # (find-man "8 ntpdate") sudo /usr/sbin/ntpdate-debian -s -b -v date ##### # # clock, ntp and timezone on etch # 2007jun07 # ##### # (find-available "ntp-simple") # (find-available "ntp-simple" "transition package") # (find-status "ntp") # (find-vldifile "ntp.list") # (find-udfile "ntp/") # (find-status "baseconfig") # (find-vldifile "baseconfig.list") # (find-udfile "baseconfig/") # (find-vldifile "ntp-simple.list") # (find-udfile "ntp-simple/") zgrep tzconfig /home/edrx/snarf/http/ftp.debian.org/dists/etch/Contents-i386.gz # (find- # (find-fline "/usr/sbin/tzconfig") # (find-fline "/usr/bin/tzselect") # (find-fline "/etc/" "localtime") # (find-fline "/etc/localtime") # (find-fline "/usr/share/zoneinfo/") # (find-fline "/usr/share/zoneinfo/America/Sao_Paulo")  (eepitch-shell) sudo tzconfig y 2 Sao_Paulo  (eepitch-shell) sudo tzselect 2 9 8 1 # You can make this change permanent for yourself by appending the line # TZ='America/Sao_Paulo'; export TZ # to the file '.profile' in your home directory; then log out and log in again. ##### # # setting daylight savings time by hand # 2007oct18 # ##### # «setting-DST-by-hand» (to ".setting-DST-by-hand") # http://en.wikipedia.org/wiki/Zoneinfo # http://www.twinsun.com/tz/tz-link.htm # http://en.wikipedia.org/wiki/List_of_tz_zones_by_country # http://en.wikipedia.org/wiki/UTC-3 # http://www.php.net/manual/en/timezones.php # ftp://elsie.nci.nih.gov/pub/tzdata2007h.tar.gz # ftp://elsie.nci.nih.gov/pub/tzcode2007h.tar.gz # rm -Rv ~/usrc/tz/ mkdir ~/usrc/tz/ tar -C ~/usrc/tz/ -xvzf $S/ftp/elsie.nci.nih.gov/pub/tzdata2007h.tar.gz tar -C ~/usrc/tz/ -xvzf $S/ftp/elsie.nci.nih.gov/pub/tzcode2007h.tar.gz # # (code-c-d "tz" "~/usrc/tz/" :grep) # (find-tzfile "") # (find-tzgrep "grep -niH -e Paulo *") # Local Variables: # coding: no-conversion # ee-delimiter-hash: "\n#\n" # ee-delimiter-percent: "\n%\n" # ee-anchor-format: "«%s»" # End: