Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 12-01-2007, 06:45 AM   #1
LQ Newbie
Registered: Aug 2007
Posts: 28

Rep: Reputation: 15
crontab to add default gateway


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

route add default
crontab entry:
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
Old 12-01-2007, 06:56 AM   #2
Senior Member
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 97
what happens when you run this from the command line?

If you are using bash try changing the file to:
route add default gw
Try changing the crontab entry to:
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.
Old 12-01-2007, 08:33 PM   #3
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,417

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
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.
Old 12-01-2007, 09:19 PM   #4
LQ Guru
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 235Reputation: 235Reputation: 235
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.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
can't seem to add a default gateway thedeep Linux - Networking 2 06-27-2007 12:31 AM
add sunnet mask & default gateway Dawar Linux - Networking 3 01-25-2007 09:36 PM
Guardian OS - cannot add default gateway thejackel Linux - Server 1 08-27-2006 08:12 AM
How to add default gateway in /etc/sysconfig/network-scripts/* zamri Linux - Networking 2 09-06-2005 11:32 AM
how do I add script to set default gateway on boot for eth1 abg Linux - Networking 3 10-01-2003 06:22 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:01 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration