LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-26-2008, 10:44 PM   #1
3erg
LQ Newbie
 
Registered: Mar 2008
Posts: 2

Rep: Reputation: 0
Arrow start-up and shut-down bash script on ubuntu 6.06.1 PPC


I have an iBook G3 and it has a problem setting the hardware clock.
Every time it is rebooted without the network cable plugged in the system clock is set to the hardware clock (Monday 04 Jan 1904).
This incorrect date is coursing problems with alot of things.

I don't care about having the correct date and time, I just want it to boot without the network cable plugged in and still work.

My plan is to run a start-up/shut-down script. On shut-down it will take the current correct date of the system, save it in a file then retrieve it at the next boot unless the network cable is plugged in, then it will get the correct ntp time.

I know this will make the date incorrect when the network is unavailable but at least the computer will work.

I am noob at scripting so much help appreciated.

#I run Ubuntu 6.06.1 with the Xubuntu desktop on an apple iBook G3 700Mhz (Duel USB)

p.s.
I have tried the Apple PRAM and PMU resets still date is stuck in the past.
 
Old 03-27-2008, 11:48 AM   #2
cmnorton
Member
 
Registered: Feb 2005
Distribution: Ubuntu, CentOS
Posts: 585

Rep: Reputation: 35
Many Problems From One Question

I suggest you play around with this. There are lots of pieces to your solution and perhaps a simple answer. Why not enter

sudo date mmddhhmm

when you log in?

As to saving your last good date in a form that could be used by the date command later on here are some examples of saving and using the saved value to set the date.

#!/bin/bash

echo `date +"%m%d%H%M"` > last_good_date

As to setting your date string back

#!/bin/bash

exec 3< last_good_date

while read LINE <&3; do
date_str=$LINE
done

date $date_str

These represent two different shell scripts, which when saved, need to have execute permissions chomd +x <file_name>

As to whether the network is up, you could test the output of running ntp, and if is non 0, then you'd set the date.

Last edited by cmnorton; 03-27-2008 at 11:52 AM. Reason: Add more stuff
 
Old 03-27-2008, 01:58 PM   #3
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 234Reputation: 234Reputation: 234
Why is the hardware clock: "(Monday 04 Jan 1904)"? Is it broken?
 
Old 03-28-2008, 12:07 AM   #4
3erg
LQ Newbie
 
Registered: Mar 2008
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks for the replies. The hardware clock now seems to be working but as a precaution I have written a simple script to check the date.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make a bash script to start & end apache and mysql ? rova Programming 2 03-01-2008 07:27 PM
Get script to start again at a certain point in the script (bash) helptonewbie Programming 11 01-11-2008 05:49 AM
using cron to start and stop a bash script monty Linux - Software 2 03-20-2006 02:30 PM
Script to start/shut down amule not working Adony Linux - Newbie 0 06-18-2004 08:23 PM
help!...suse 9 gome won't shut off...or start reillac Linux - Newbie 14 01-03-2004 04:17 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:02 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration