There is this code that claims to set the time of your Linux environment,http://blog.petrilopia.net/linux/raspberry-pi-set-time-gps-dongle/date -s '01/01/2014 00:01'sleep 1pkill ntpdpkill gpsdgpsd -b -n -D 2 /dev/ttyUSB0sleep 2GPSDATE=`gpspipe -w | head -10 | grep TPV | sed -r 's/.*time:([^]*).*/\1/' | head -1`echo $GPSDATEdate -s $GPSDATE/usr/sbin/ntpdBut When I am running this code through puTTy it sets my time to,Sun Aug  8 06:08:11 PKT 2010I'd like to know why it is setting my GPS time to 2010 while its 2013.Here is the Output of gpspipe -w command{class:TPV,tag:MID2,device:/dev/ttyUSB0,mode:1,time:1990-12-22T23:59:53.020Z,ept:0.005}{class:TPV,tag:MID2,device:/dev/ttyUSB0,mode:1,time:1990-12-22T23:59:54.020Z,ept:0.005}{class:SKY,tag:MID4,device:/dev/ttyUSB0,time:1990-12-22T23:59:55.010Z}{class:TPV,tag:MID2,device:/dev/ttyUSB0,mode:1,time:1990-12-22T23:59:55.010Z,ept:0.005}{class:TPV,tag:MID2,device:/dev/ttyUSB0,mode:1,time:1990-12-22T23:59:56.020Z,ept:0.005}{class:TPV,tag:MID2,device:/dev/ttyUSB0,mode:1,time:1990-12-22T23:59:57.020Z,ept:0.005}The output is continuous, which means it is changing every second.
Setting time through GPS dongle
time;satellite
Since $GPSDATE is being reported as Sun Aug 8 06:08:11 PKT 2010the date -s command is doing exactly what you are telling it to do. Why is it reporting a wrong year (or nothing at all)? I have no idea.Since you are already using ntpd why are you not content to let NTP do its thing? Is this an I'd like gpsdate to work because it is there issue? The best way to help us help you debug this it by giving the full output of gpsdate -win your question.added in response to gpsdate output:According to the gpsd documentation when the mode field of a TPV record is 1 it means no fix. This means that the GPS receiver has not seen enough (or any) satellite data. This implies that the time value is junk which certainly makes sense if you are seeing a year of 1990 or 2014. In your script, the sleep 2 gives very little time for gpsd to get a proper GPS fix. Waiting longer might help, not having a proper antenna attached means you will wait forever for a fix.The Network Time Protocol implemented by ntpd does not need GPS to work. It exchanges time synchronization information with other internet hosts, some of which do get their clock from a reference like GPS. Since your script stops and restarts your ntpd, you could just forget about a GPS fix and work with that. For example, the machine I am typing this on uses ntpd and is +4.7 milliseconds off of UTC which is more than accurate for many purposes. You can use ntpq -p to find out if and how well your clock is synchronized.