neothematrix / noip-renew

Auto renew (confirm) noip.com free hosts
https://hub.docker.com/r/moebiuss/noip-renew
Apache License 2.0
54 stars 20 forks source link

Randomize the crontab mm:hh entry? #42

Closed jmb365 closed 9 months ago

jmb365 commented 1 year ago

Hello,

I wonder if randomizing the time when the next job should run is of interest. I decided to try it:

sudo cp /usr/local/bin/noip-renew-skd.sh /usr/local/bin/noip-renew-skd.sh.orig sudo nano /usr/local/bin/noip-renew-skd.sh

Then add the following:

Min=$(/usr/bin/shuf -i 0-60 -n 1) Hr=$(/usr/bin/shuf -i 9-15 -n 1)

Finally, I altered:

CRONJOB="$Min $Hr $INSTEXE $LOGDIR" NEWCJOB="$Min $Hr $1 $2 $INSTEXE $LOGDIR"

Let me know if it is a good or bad idea. Thanks! JMB

Angel0ffDeath commented 1 year ago

@jmb365 Maybe not bad idea. However I would prefer this job to run between midnight and 5 AM. Probably most of the others will agree with me... Firm time is also working for me

michaelschon commented 1 year ago

Min=$(/usr/bin/shuf -i 0-60 -n 1) Hr=$(/usr/bin/shuf -i 9-15 -n 1)

Finally, I altered:

CRONJOB="$Min $Hr $INSTEXE $LOGDIR" NEWCJOB="$Min $Hr $1 $2 $INSTEXE $LOGDIR"

I loved!

Angel0ffDeath commented 10 months ago

@jmb365 I tried it. And I really liked it. A few suggestions:

  1. setup.sh to manipulate noip-renew-skd.sh during installation to do item 2 below.
  2. Hr to be configurable from setup.sh and to alter directly the script with sed command (or with parameters, but with sed will be easier), taking into account to avoid (if possible) running hours between 3AM and 4AM (this is for Europe, I don't know for other countries when this event occurs) since daylight can occur and code not to run or to run twice. This one occurred by me end of October - running code twice due to DST ending.
  3. Finally - PR. @neothematrix didn't close this issue so probably he will merge it. If you need assistance let me know.

Of course you can reject my suggestions above

neothematrix commented 10 months ago

hello all and thanks for your comments and suggestions! As I don't currently use crontab because I run no-ip as docker container, if you think this is a useful change, please feel free to submit a pull request and I'll happily merge it!

thanks!