LinHES Forums http://forum.linhes.org/ |
|
Keep your system on time with this script... http://forum.linhes.org/viewtopic.php?f=11&t=6534 |
Page 1 of 1 |
Author: | Girkers [ Fri Oct 21, 2005 4:48 pm ] |
Post subject: | Keep your system on time with this script... |
Folks, here is a script to update the time of your system only a daily basis as well as on every boot. Once you have run this script you will need to reboot your system for the script to take effect. Code: #!/bin/sh
# Written by Girkers # with help from mjl # and tjc #Default Variables sys=""; quest="Do you want to enable "; ans="? [yn]:"; choice=""; #Remove the ntpd from running update-rc.d ntpd remove #Set the computer to keep time via a time server #Daily and on a boot echo sys="KnoppMyth box to update its clock via the Net"; read -n1 -p "$quest$sys$ans" choice choice=$(echo $choice | tr "[a-z]" "[A-Z]") echo if [[ ${choice} = "Y" ]]; then region="" echo echo "Pick your time zone area via the corrosponding number:" echo "1 - Asia" echo "2 - Europe" echo "3 - North America" echo "4 - Oceania" echo "5 - South America" zone="" while [ -z "$zone" ] ; do read -n1 -p "Which region are you in:" region case "$region" in 1) zone=asia ;; 2) zone=europe ;; 3) zone=north-america ;; 4) zone=oceania ;; 5) zone=south-america ;; *) echo "You must enter a number between 1 - 5";; esac done echo echo "Please wait; applying your settings..." # Set the time to update from the net for FILE in /etc/cron.daily/mythtv-backend /etc/init.d/bootmisc.sh ; do [ -f "$FILE" ] && cp "$FILE" "$FILE.old" && sed -e "/ntpdate/d" <$FILE >$FILE.new echo "/sbin/ntpdate $zone.pool.ntp.org &" >>"$FILE.new" && mv "$FILE.new" "$FILE" done echo echo $sys "command complete" else echo $sys "skipped" fi |
Author: | ceenvee703 [ Fri Oct 21, 2005 7:49 pm ] |
Post subject: | |
I like the script: there's some typos in the text. "KnoppMyth box to update its clock via the Net"; "corresponding number"; "Please wait: applying your settings..." |
Author: | kmkittre [ Sun Oct 30, 2005 12:45 pm ] |
Post subject: | |
I get the following errors when I try and run your script: Code: root@mythtv:~# sh timeupdate.sh
: command not found 5: : command not found 7: : command not found 8: : command not found 9: : command not found 10: : command not found 11: update-rc.d: /etc/init.d/ntpd: file does not exist : command not found 14: : command not found 17: echo : command not found 18: Do you want to enable KnoppMyth box to update its clock via the Net? [yn]:ytimeu': not a valid identifier`choice : command not found 21: echo 'imeupdate.sh: line 34: syntax error near unexpected token `in 'imeupdate.sh: line 34: ` case "$region" in |
Author: | tjc [ Sun Oct 30, 2005 1:32 pm ] |
Post subject: | |
I suspect that you botched the cut and paste somehow. You shouldn't need to prefix the script name with sh since it has the appropriate #! magic on the first line. All you need to do is set the execute bit (chmod +x timeupdate.sh) and run it. That said, does bash -n timeupdate.sh show trhe same errors? I just did that on my system without any problems. |
Page 1 of 1 | All times are UTC - 6 hours |
Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |