LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


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

Rep: Reputation: 15
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
 
Old 12-01-2007, 06:56 AM   #2
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
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.
 
Old 12-01-2007, 08:33 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,417

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

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


Reply


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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

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