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: Scripting
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment