Timezone change aid

Steve Losen scl at virginia.acc.virginia.edu
Tue Apr 5 05:38:28 AEST 1988


Here is a little shell script to be run from cron *every* night to be  sure
that  your timezone variable is set properly. We wrote this because we have
~100 3b systems that all have to deal with that nasty  period  between  the
first  Sunday in April and the last one. Last year we had a cron set to run
on the first Sunday in April to change the /etc/TIMEZONE file  and  another
cron  to  set it back on the last Sunday. This was a disaster since not all
of our machines were up when the crons were supposed to  run.  This  script
knows what /etc/TIMEZONE is supposed to look like no matter when it is run.

====cut====
set `date`

file=/etc/TIMEZONE
line="TZ=EST5EDT; export TZ"
day=$1
month=$2
num=$3

if [ "$month" = "Apr" ] ;then

    case $day in
      Sun)  lower=0; upper=24;;
      Mon)  lower=1; upper=25;;
      Tue)  lower=2; upper=26;;
      Wed)  lower=3; upper=27;;
      Thu)  lower=4; upper=28;;
      Fri)  lower=5; upper=29;;
      Sat)  lower=6; upper=30;;
    esac

    if [ $num -gt $lower -a $num -lt $upper ] ;then
       line="TZ=EDT4; export TZ"
    fi
fi

echo "$line" > $file
====cut====

-- 
Steve Losen     scl at virginia.edu
University of Virginia Academic Computing Center



More information about the Comp.sys.att mailing list