LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   [root] Changing time without using ntp/ntpdate ? (https://www.linuxquestions.org/questions/linux-newbie-8/%5Broot%5D-changing-time-without-using-ntp-ntpdate-571404/)

frenchn00b 07-22-2007 01:04 PM

[root] Changing time without using ntp/ntpdate ?
 
I saw that :
Code:

# hwclock --set --date="05/18/2007 18:00:00"
# hwclock --hctosys

could change the date. But it is not working.
what could be failing point I missed ?

also, at the boot, the debian etch is checking the time from server, that couldnt be changed or set to a ntp , and this without affecting/telling that to the BIOS ?


________

I finally found it works with directiva option.
damn, not so easy

__
http://linux.die.net/man/8/hwclock

frenchn00b 07-22-2007 03:53 PM

rather solved.
I made a script to configure the time and date, starting at boot in /etc/rc2.d/S21myscripttime

with XXXXXXXXXXXXXXXXX number of my city
Code:

elinks "http://www.timeanddate.com/worldclock/city.html?n=XXXXXXXXXXXXXXXXX"  > timetown.htm

cat timetown.htm  | grep CEST > timetown

pyear="$(    cat  timetown | awk ' NR==1 {  print $5  }  '  |  awk  '{ gsub (",", "") ; print  }  '      )"
pmonth="07"
pday="$(cat  timetown | awk ' NR==1 {  print $4  }  '  |  awk  '{ gsub (",", "") ; print  }  '  )"

ptime="$(  cat  timetown | awk ' NR==1 {  print $7  }  '  |  awk  '{ gsub (",", "") ; print  }  '  )"

pheure="$(echo "$ptime" | awk '  {  n=split($1 , vk , ":")  ;  print vk[1]        }                ')"
echo $pheure + 12 | bc

echo "the text:--$pyear/$pmonth/$pday $ptime--"

if [  "$(cat  timetown | awk ' NR==1 {  print $8  }  '  |  awk  '{ gsub (",", "") ; print  }  ')"  == "PM" ] ; then
        pheure="$(echo $pheure + 12 | bc )"
        pmin="$(echo "$ptime" | awk '  {  n=split($1 , vk , ":")  ;  print vk[2]        }                ')"
        psec="$(echo "$ptime" | awk '  {  n=split($1 , vk , ":")  ;  print vk[3]        }                ')"
        ptime="$pheure:$pmin:$psec"
fi
echo "the text:--$pyear/$pmonth/$pday $ptime--"
valuetime="$pmonth/$pday/$pyear $ptime"
echo "the time is $valuetime"
sudo hwclock --directisa --set --date="$valuetime"
sudo hwclock --directisa --hctosys
echo "$valuetime configured to"
echo "the date:"
date
echo "--"

it works.

So, I have two questions:
Is this script harmful ? Is this script affecting the Bios (it looks that not but i am not sure) ?



---


All times are GMT -5. The time now is 01:34 AM.