I was working with few testers who need to change the system time occasionally on a linux box. Most of the time, they had problem while issuing the date command. Below one is a menu based shell script to update time on a linux box (xen guest in this case)
#!/bin/bash
Author : basil@
Purpose : Menu based date/time change of Linux boxes with ntpdate
Date : 04-20-2009
# Below kernel parameter is to allow xen guest take independent decision about its clock.
echo 1 > /proc/sys/xen/independent_wallclock
while :
do
clear
echo "-------------------------------------"
echo " Main Menu "
echo "-------------------------------------"
echo "[1] Show Todays date/time"
echo "[2] Change System time"
echo "[3] Show calendar"
echo "[4] Change System time to Current time"
echo "[5] Exit/Stop"
echo "======================="
echo -n "Enter your menu choice [1-5]: "
read yourch
case $yourch in
1) echo "Today is `date` , press Enter/Return key. . ." ; read ;;
2) echo "Enter new date and time [Format: MMDDHHMMYYYY]: ";read newtime ; date $newtime;echo "Today is `date`, , press Enter/Return key. . ." ; read ;;
3) /usr/bin/cal; echo "Press a key. . ." ; read ;;
4) echo "Updating to Current time..."; `/usr/sbin/ntpdate -s clock.redhat.com`;echo "Today is `date`, , press Enter/Return key. . ." ; read ;;
5) exit 0 ;;
*) echo "Opps!!! Please select choice 1,2,3 or 4";
echo "Press Enter/Return key. . ." ; read ;;
esac
done
Menu Based - Time changing Script
Tuesday, July 7, 2009 Posted by admin at 2:57 PM | Labels: ScriptingTime Sync issues - VMware Guest Hosts
Monday, July 6, 2009 Posted by admin at 4:23 PM | Labels: vmware
I was damn tired of time sync issues related to guest hosts running on top of VMware ESX 3.5 host. Even though I have installed ntp client on all the servers, but still the guest OS's are running out of Sync.
NTP Recommendations
VMware Tools time synchronization configuration
- Set tools.syncTime = "0" in the configuration file (.vmx file) of the virtual machine.
OR - Deselect Time synchronization between the virtual machine and the host operating system in the VMware Tools toolbox GUI of the guest operating system.
OR - Run the vmware-guestd --cmd "vmx.set_option synctime 1 0" command in the guest operating system.
Virtual Hardware clock configuration
64bit Kernels
Linux Flavor | Version | Kernel Parameters | Notes |
RHEL | | | |
RHEL 5.3 | notsc divider=10 | ||
| RHEL 5.2 | notsc divider=10 | |
| RHEL 5.1 with RHSA-2007:0993-13 | notsc divider=10 | |
| RHEL 5.1 without RHSA-2007:0993-13 | notsc |
32bit Kernels
Linux Flavor | Version | Kernel Parameters | Notes |
RHEL | |||
RHEL 5.3 | divider=10 clocksource=acpi_pm | ||
RHEL 5.2 | divider=10 clocksource=acpi_pm | ||
RHEL 5.1 | divider=10 clocksource=acpi_pm | ||
RHEL 5.0 | clocksource=acpi_pm |
Editing Kernel Configuration
For LILO, put the kernel command line parameters at the end of the "append" line. For example, if the append line looks like:
append="resume=/dev/hda6 splash=silent"
and you want to add "clock=pmtmr divider=10" the updated text is:
append="resume=/dev/hda6 splash=silent clock=pmtmr divider=10"
Remember to run /sbin/lilo after editing lilo.conf , so that your edits take effect.
For GRUB, put the kernel command line parameters at the end of the "kernel" line. For example if the kernel line looks like:
kernel /vmlinuz-2.6.18 ro root=/dev/hda2
and you want to add "clock=pmtmr divider=10" the updated text is:
Below given is the best practice, for time related issues on VMware guests.kernel /vmlinuz-2.6.18 ro root=/dev/hda2 clock=pmtmr divider=10
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1006427