Help needed with CronJob!

I am having a trouble with one of my Dreambox's route which keeps dropping for some reason, so a friend told me to create a Cron Job to add route.

Can I just do?:

          • route add -net 192.x.x.x netmask 255.x.x.x gw 192.x.x.x

Or do I need something else to work like a script to check if the route is still there and add it if its not or something similar?

Posted May 16, 2018, 10:11 AM UTC

64
Swedophone•

Is the route found in the PATH used by cron?

1
nuncio-tc•

as already mentioned, check to see if route is in the $PATH of the user that will be running this job - note, you'll need to do it as root or another user that can add routes via sudo without a password.

Having said that, I'd recommend looking into up route instead, cron isn't the way to do this. The implementation varies from distro to distro ( at least I think it does) but the idea is that you make this route part of your permanent network config so every time the interface comes up, the route gets added.

[edit] after re-reading, I see you mention that it's dropping which makes me think it's there already and you know about up routes, maybe. Sorry if that's the case. You could likely resolve it via cron but you may want to look into why it keeps dropping - syslog etc.

1
ostensibly_work•

note, you'll need to do it as root or another user that can add routes via sudo without a password.

You can also change the sudoers file to allow running a script as root without using a password. Though I'm not sure if that's what's needed here.

1
technolojeeesus•

If the route drops it's presumably because you're adding the route by hand and the interface is bounced - just add the routes to your ifup scripts...

1