LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   crontab to add default gateway (https://www.linuxquestions.org/questions/linux-newbie-8/crontab-to-add-default-gateway-603715/)

daemonkl 12-01-2007 05:45 AM

crontab to add default gateway
 
hi!

i need help on crontab adding default gateway
i have mad my own crontab to check default gateway every 10 mins. but it did not work

my codes:
[mad@localhost ~]$ ls -la gateway
-rwxr-x--x 1 mad mad 35 Dec 1 15:17 gateway

Quote:

route add default 192.168.1.1
crontab entry:
Quote:

0,10,20,30,40,50 * * * * /home/mad/gateway >/dev/null 2>&1
can someone recorrect cause it did not work for me
thank you in advanced

Disillusionist 12-01-2007 05:56 AM

what happens when you run this from the command line?

If you are using bash try changing the file to:
Code:

#!/bin/bash
route add default gw 192.168.1.1

Try changing the crontab entry to:
Code:

0 * * * * /home/mad/gateway >/tmp/output 2>&1
Then check the output file for any clues to whats going wrong.

I am assuming that the user for the crontab is the same user that you tested the script.

chrism01 12-01-2007 07:33 PM

cron has a minimal default env, specifically the PATH variable.
Always specify the entire/absolute path to any prg or data file if called from within the cron env.
eg
/sbin/route

trickykid 12-01-2007 08:19 PM

Why would you need to update your default route or gateway that often? It shouldn't change at all unless you have another process changing it which seems sort of odd.


All times are GMT -5. The time now is 08:07 PM.