4

I have a "windriver" linux based Wimax ASN, and when ever I login, I find the date and time is wrong (example: "15 jul 2010").

Whenever I set both the date and time with the date command, or the hwclock, it returns back to old state "15 jul 2010" right after I log out and in again, without even restarting the device.

Is there any way to permanently set them both without using NTP?

8

If you don't wish to use the NTP command, see if this works as an alternative for you:

date -s "$(curl -s --head http://google.com | grep ^Date: | sed 's/Date: //g') -0500"

**Note: The time pulled from Google, is in GMT, so the -0500 represents the numeric timezone you are in. For me I am in US/EST so that is -0500, please change yours to match to your respective timezone, and it should fix any 'local time offsets' you might be experiencing.

If it isn't sticking every time you log out and log back in, you can try setting this in your .bash_profile or /etc/profile so that it runs first every time you log in, it isn't a 'fix' but more of a 'hack'.

  • Thank you Dev, it worked , but the time was 00:00:00 at the moment i ran the command, where should i change in the line u post to set the exact time? – Sharista Dec 26 '15 at 6:05
  • If you want the exact time, you should use a time service, like NTP. – Jeff Schaller Dec 26 '15 at 6:08
  • Hi Jeff, i mean setting it with the same command that Dev sent if possible, because all fine now regarding date and time , both been saved well , but i have a drift in some hours:minuts cause i did not enter time in Dev's command. – Sharista Dec 26 '15 at 6:35
  • @Sharista, do you just not want to use the ntpd but are ok with ntpdate or do you not wish to use either? Because if you are ok with using ntpdate, you can just cron something like 0 0 * * * /path/to/ntpdate <ntpserver> – devnull Dec 26 '15 at 13:27
  • @DevNull i do not want to use ntpd at all, i mean setting date and time manually, the date now is good thanks to u, but with wrong time(shifted some hours cause when i ran ur line , i was almost 9 hours past 00:00:00). – Sharista Dec 26 '15 at 13:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.