ntpdate comes installed in the White Light MBWE but contains a bug in that it sometimes doesn't sync the time on boot. You can use cron to keep it updated by adding the following to your /opt/etc/crontab
0 4 * * * root ntpdate pool.ntp.org
Then restart cron:
~ # /opt/etc/init.d/S10cron stop ~ # /opt/etc/init.d/S10cron start
This page describes a method to keep date and time of your MyBook actual without using ntpd service. Instead ntpdate is used for updating the time after reboot and once every day.
All commands given in this tutorial have to be run as user root.
Disable ntpd service
Ntpd service is disabled by commenting it out in /etc/init.d/ntp.sh.
Create time update script
You need a server from where you can get the time from. In this HowTo a server of the PTB in Germany (ptbtime1.ptb.de) is used, but it is possible to use another server if available.
Create the script timeupdate.sh using a text editor (e.g. vi) with the following content
# update the time using ntpdate
/usr/bin/ntpdate -b ptbtime1.ptb.de >/dev/null 2>&1
Save the script in the directory you want, e.g. /root and make it executable with
# chmod 755 <path>/timeupdate.sh
Where <path> is the path to your timeupdate.sh. Example: # chmod 755 /root/timeupdate.sh
Updating time after reboot
To update the time direct after reboot the script timeupdate.sh must be called. This is done by creating a symbolic link in/etc/init.d. We use the behaviour of the S[number] scripts.
The scripts in the directory "/etc/init.d/" starting with "S[number]" are automatically run during system startup with parameter "start". The number defines the order the scripts are run. Likewise, scripts starting with "K[number]" are run when the system is shutting down with parameter "stop". (from http://kyyhkynen.net/stuff/mybook/spindown.php)
Create the link and make it executable.
# ln -s <path>/timeupdate.sh /etc/init.d/S[number]timeupdate
# chmod 755 /etc/init.d/S[number]timeupdate
Where [number] is a free number. Please check if your number is not already used. <path> is the path to your timeupdate.sh. For example: # ln -s /root/timeupdate.sh /etc/init.d/S95timeupdate
Updating time every day
Insert the following line to your /etc/cronjobs/root. Make sure that you enter the correct path to the script.
0 8 * * * /root/timeupdate.sh
This line executes timeupdate.sh every day at 8 am. It is possible to use other times.
After changing /etc/cronjobs/root the cron job has to be re-started. To re-start you have to stop it with
# /etc/init.d/crond.sh stop
and then start again with
# /etc/init.d/crond.sh start
Adjusting timezone is also necessary for recognizing the correct date/time of changes of daylight saving times. This has to be done by changing the value in /var/etc/TZ (there is a symbolic link in /etc/TZ).
The value depends on the place you are living.
The following table shows kown values of /var/etc/TZ. Please add proved values for other countries!
|Country||value of /var/etc/TZ|
|North America Eastern Time Zone||EST+5EDT+4,M3.2.0/02:00:00,M11.1.0/03:00:00|
To change the value of /var/etc/TZ use the following commands.
Please save your current version of /var/etc/TZ first. The command copies the TZ file to a file TZ-with_date_time
# cp /var/etc/TZ /var/etc/TZ-`date +%Y-%m-%d`
Write new value to /var/etc/TZ. Replace <value> with your specific value string.
# echo "<value>" >/var/etc/TZ
For example for Germany use # echo "CET-1CEST-2,M3.5.0/02:00:00,M10.5.0/03:00:00" >/var/etc/TZ
Format of /var/etc/TZ
In POSIX.1 systems the value of the TZ variable can be in one of three formats.
Here the format used in MyBook is described. The common format is:
std offset dst [dstoffset],start[/time],end[/time]
The std string specifies the name of the time zone. It must be three or more characters long and must not contain a leading colon, embedded digits, commas, nor plus and minus signs.
The following offset specifies the time value you must add to the local time to get a Coordinated Universal Time value. It has syntax like [+|-]hh[:mm[:ss]]. This is positive if the local time zone is west of the Prime Meridian and negative if it is east. The hour hh must be between 0 and 23, and the minute mm and seconds ss between 0 and 59.
The dst string and dstoffset specify the name and offset for the corresponding Daylight Saving Time zone; if the offset is omitted, it defaults to one hour ahead of standard time.
The remainder of the specification describes when Daylight Saving Time is in effect. The start field is when Daylight Saving Time goes into effect and the end field is when the change is made back to standard time. The following format is recognized for these fields start and end:
|Jn||This specifies the Julian day, with n between 1 and 365. February 29 is never counted, even in leap years.|
|n||This specifies the Julian day, with n between 0 and 365. February 29 is counted in leap years.|
|Mm.w.d||This specifies day d of week w of month m. The day d must be between 0 (Sunday) and 6. The week w must be between 1 and 5; week 1 is the first week in which day d occurs, and week 5 specifies the last d day in the month. The month m should be between 1 and 12.|
The time fields specify when, in the local time currently in effect, the change to the other time occurs. It has syntax like hh:mm:ss. If omitted, the default is 02:00:00.
Note: There are no space characters separating the different parts of the format string, but they are necessary to make the format string human readable.
For example, here is how you would specify the Central Europe time zone in Germany, including the appropriate Daylight Saving Time and its dates of applicability. The normal offset from UTC is 1 hour; since this is east of the prime meridian, the sign is negative. Summer time begins on the last Sunday in March at 2:00am, and ends on the last Sunday in October at 3:00am.