What's new

How to start Transmission after clock is adjusted by NTP?

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

I looked at the fake-hwclock but it looks like it only saves the time on a clean shutdown... On a crash or power fail, it'll just load time from days or weeks or months ago...
 
Last edited:
Sure. That's why it's called *fake*-hwclock, no any script can bring a real time clock to router. You may run fake-hwclock from cron once per hour (if ±½ of hour accuracy is acceptable for your needs).
 
As for me, I put fake-hwclock right into JFFS partition, it's just a shell script. Check this out, router got actual time at 7 second of boot. \w/ :)
Could you share what you did to put it into jffs? Pretty sure I didn't do something right when I tried testing this out. Thanks.
 
Code:
opkg install fake-hwclock
cp /opt/bin/fake-hwclock /jffs/scripts/
opkg remove fake-hwclock
Now change FILE=/opt/etc/fake-hwclock.data to FILE=/jffs/fake-hwclock.data in /jffs/scripts/fake-hwclock with your favourite text editor.

Script is ready, you have to call it on boot…
Code:
# cat /jffs/scripts/init-start
#!/bin/sh
/jffs/scripts/fake-hwclock load
…and on shutdown:
Code:
# cat /jffs/scripts/services-stop
#!/bin/sh
/jffs/scripts/fake-hwclock save
 
Sure. That's why it's called *fake*-hwclock, no any script can bring a real time clock to router. You may run fake-hwclock from cron once per hour (if ±½ of hour accuracy is acceptable for your needs).
Yes.. Agreed. I just thought it should be daemonized. cru would work though.
 
As for me, I've added fake-hwclock after falling into following trap:
  • WiFi scheduler is set to turn the radio off for all night,
  • Rebooting router while Internet is down for some reason (manually, power glitch, whatever),
  • Router can't get actual time, so it disables radio (because thinks it's a night:)),
  • I can't reach router via WiFi anymore.
BTW, fake-hwclock is implemented in Padavan's f\w project to prevent this situation.
 
@ryzhov_al This justifies your use of f hwclock. In general, I can't think of why ppl need it. I thought it was a generic fix to timezone issue in some Entware apps. It's not! lol

Thinking over the TZ thing. A better trick will be to add:
Code:
export TZ=$(cat /etc/TZ)
right before $PRECMD line in start() function inside rc.func.

This is generic then to all Entware apps which might have the issue. No per app based change needed. No hand crafting TZ string either.
 
BTW, you can check the nvram flag "ntp_ready". If it's set to 0, then it means that the ntpclient hasn't successfully synchronized the clock yet. So you can put stuff into a loop that checks for that nvram flag, and sleep 5-10 secs between checks.
 

Similar threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top