Scheduled pppoe reconnect (specific time)

Just use cron, like e.g. (with a good hour of hysteresis):

0 5 * * * [ $(ifstatus wan | jsonfilter -e '@.uptime') -lt 3650 ] || ifup wan
2 Likes

Since he wants a specific time it makes sense to use cron but just ifdown and ifup every night at 1:23 or whatever

While there may be reasons for an exact daily reconnect, most home uses are more interested in scheduling it to an off time.

Consider the case where the ISP disconnects at 04:58, do you really want to disconnect again at 05:00 just because that's the time you've set for your prophylactic reconnect? It's obviously easy to change the safety margin in my example above - for my uses over several years one hour an five seconds were a good compromise, but nothing speaks against reducing it to 5 minutes or less. (I've picked slightly more than one hour to avoid issues with clock skew and ISPs having interesting definitions of daylight saving).

I think the point is he doesn't want the connection to ever go down between normal hours like say 5am to 11pm. This isn't about the ISP occasionally disconnects and we need to notice it within 5 minutes, it's about the ISP requires you to re-authenticate via pppoe once every 24 hours and we always want it to be early in the morning before anyone wakes up.

Principle of using cron still applies, but it'd be something like:

34 3 * * * ifdown ppoe-wan; sleep 30; ifup pppoe-wan
1 Like

...and guess what my example actually does.

It looks like it checks every 5 minutes to see that the up time is less than 1 hr and 50 seconds and if not it brings up wan... Which is maybe not really what you intended, but whatever, the OP can get the idea

If that were the case, your example would trigger every 3 minutes? I think not, yes cron has a weird syntax, but it hasn't changed in decades. Also "ifup wan" has an interesting side effect for PPP(oE) connections, yes it brings up the interface - but in order to do that, it first...

Thanks for ur input guys, i need to read and understand Cron first.
With my ISP you'll get a new IP every 24 hours and ofc i dont want the reconnect to be done in the primetime where lot of people using the internet here...

08:00 in the morning would be perfect for me.

0 8 * * * ifdown ppoe-wan; sleep 30; ifup pppoe-wan
or
0 8 * * * ifup pppoe-wan

I dont understand the sleep command.
Wouldnt the second one gets the job done as simple as possible ?
I'll give it a try now...

edit:
I've tried 40 9 * * * ifdown pppoe-wan; ifup pppoe-wan to test if it works, but it didn't.
No reconnect and no sign in the sytsemlog.
My Timezone is correctly set in luci and the router time matches my local time so i dont know what's the problem.

@slh That's what I get for reading things on my phone while my kids play at the park, yes, every 5 minutes would be

*/5 * * * *

@kherby yes I wasn't aware that ifup would drop the connection first, did you get the crontab in place substantially before 9:40 local time? Because cron needs to see it in time to process it. Try setting the time to say 3 minutes ahead of the current time just to be sure cron notices.

Yes i did that, for some reason the cron job doesnt work for me. What im doing wrong ?
As i said my timezone is correct and the router time fits my local time.... I'm confused :confused:

Is cron running? Are you editing the right file? Do you have syntax issues? Not sure if lede uses standard cron, maybe lede version needs restart to notice changes?

In LUCI there's a warning: "Note: you need to manually restart the cron service if the crontab file was empty before editing." so try restarting cron

i did

/etc/init.d/cron start
/etc/init.d/cron enable

after saving the via Scheduled Tasks.
I'll try with a reboot later, cant do it right now.

/etc/init.d/cron restart

I think what you want

It worked without a restart, the mistake was pppoe-wan, had to replace with just wan and it worked.... So ifup wan does the job.
Thanks for your help guys. :ok_hand:

I've realised that when using a cron job to terminate and reconnect my pppoe-wan interface at a specific time my SQM-QoS will stop working after... So the desired speeds doesnt work anymore.
Any idea how to fix this ?

Hi Kherby,

seems like a genuine bug, also see https://forum.openwrt.org/t/sqm-does-not-reinitialize-after-ifup-wan/15198

Just in case, there is a commit in upstream sqm-scripts that should fix this for good. Not sure when this version will end up in openwrt.

@moeller0, thanks for letting me know about this...
Hopefully it will be fixed very soon @OpenWRT.
It confused me quite much, cause i didn't know if did a mistake somewhere within my config.
Is there a way to manualy fix this ? Just in case...

Well, sqm-scripts will first need to create a new version that incorporates that fix before the openwrt package can be updated, s this will take a while.

Sure, sorry for that.

I believe that issueing the following command from your router's command line should do the trick:

echo '[ "$ACTION" = ifdown ] && /etc/init.d/sqm enabled && /usr/lib/sqm/run.sh stop ${DEVICE}' >> /etc/hotplug.d/iface/11-sqm

Then do "cat /etc/hotplug.d/iface/11-sqm" and look at the output (and/or post it here)

If you do try "ifdown wan" followed by "tc -s qdisc" (after a short while there should be no cake/htb information left for the ifb4${WAN}), then "ifup wan" should get you back to a working sqm instance (confirm with "tc -s qdisc" where you should expect one cake or htb instances on your wan interface and the matching ifb interface; but you might need to give that some time as for example pppoe might take a few seconds to actually give you an hotplug event after issuing the ifup command.
Let me know whether that works.

Best Regards

1 Like

I'll defently try that later on, can't test it right now as i am at work :wink:
Thanks for the input....