Networking Forums

Networking Forums > Computer Networking > Linux Networking > ifconfig doesn't detect change under crontab

Reply
Thread Tools Display Modes

ifconfig doesn't detect change under crontab

 
 
Campbell
Guest
Posts: n/a

 
      02-08-2004, 01:27 PM
Hi,

I have a script that runs every 5 minutes that runs the ifconfig
command to detect the external IP address of my machine, which is
connected with a DSL modem to the Internet.

Whenever my IP address changes, the cron'd ifconfig doesn't seem to
pick up this change for about 48 hours. If I log in manually and run
ifconfig it seems to return the correct new IP address, then all of a
sudden the cron'd one returns the correct address.

I tried upgrading to the latest version of nettools (1.60 - ifconfig
1.42) but that didn't seem to make a difference.

Has anyone else experienced this, or have any ideas how to solve it?

Thanks,
Campbell
 
Reply With Quote
 
 
 
 
Cameron Kerr
Guest
Posts: n/a

 
      02-09-2004, 04:47 AM
Campbell <(E-Mail Removed)> wrote:
> Hi,
>
> I have a script that runs every 5 minutes that runs the ifconfig
> command to detect the external IP address of my machine, which is
> connected with a DSL modem to the Internet.
>
> Whenever my IP address changes, the cron'd ifconfig doesn't seem to
> pick up this change for about 48 hours...


> Has anyone else experienced this, or have any ideas how to solve it?


Not until you show us your cron entry and the script that you are
calling from it.

Most likely its a bug of some sort.

--
Cameron Kerr
(E-Mail Removed) : http://nzgeeks.org/cameron/
Empowered by Perl!
 
Reply With Quote
 
David Efflandt
Guest
Posts: n/a

 
      02-13-2004, 01:09 AM
On 8 Feb 2004 06:27:44 -0800, Campbell <(E-Mail Removed)> wrote:
> I have a script that runs every 5 minutes that runs the ifconfig
> command to detect the external IP address of my machine, which is
> connected with a DSL modem to the Internet.
>
> Whenever my IP address changes, the cron'd ifconfig doesn't seem to
> pick up this change for about 48 hours. If I log in manually and run
> ifconfig it seems to return the correct new IP address, then all of a
> sudden the cron'd one returns the correct address.
>
> I tried upgrading to the latest version of nettools (1.60 - ifconfig
> 1.42) but that didn't seem to make a difference.
>
> Has anyone else experienced this, or have any ideas how to solve it?


If using pppoe, the /etc/ppp/ip-up script will always run (with your IP as
a parameter) when you get a new ppp0 IP (I use that to update my dynamic
DNS). If using dhcp instead, then something related to whatever does your
dhcp (dhcpcd or pump) should have related scripts that can also monitor
that.

So it appears that something in your undisclosed crontab entry or script
is flawed (and apparently less reliable).

--
David Efflandt - All spam ignored http://www.de-srv.com/
 
Reply With Quote
 
Campbell
Guest
Posts: n/a

 
      03-05-2004, 05:08 PM
>
> So it appears that something in your undisclosed crontab entry or script
> is flawed (and apparently less reliable).


It's DHCP I'm using served by my DSL modem.

Thanks. I'll try and look into the dhcp scripts. In the meantime,
here is my config:

Crontab entry:
5,10,15,20,25,30,35,40,45,50,55 * * * * /path/checkip.sh >>
/path/checkip.log 2>&1

checkip.sh script:
#!/usr/bin/bash

EXTIP=`ifconfig eth1 | grep inet | cut -f2 -d":" | cut -f1 -d" "`

DATE=`date`
echo -e "[$DATE] \c"
echo -e "External IP: $EXTIP - \c"

IPFILE="/path/CurrentIP.txt"
OLDIP=`cat $IPFILE`

echo $EXTIP > $IPFILE

if [ "$EXTIP" = "$OLDIP" ] ; then

echo "Same IP, no probs."

else

echo "IP address changed from $OLDIP to $EXTIP."

<do stuff>

fi
 
Reply With Quote
 
Bit Twister
Guest
Posts: n/a

 
      03-05-2004, 05:19 PM
On 5 Mar 2004 10:08:32 -0800, Campbell wrote:
>
> checkip.sh script:
> #!/usr/bin/bash
>
> EXTIP=`ifconfig eth1 | grep inet | cut -f2 -d":" | cut -f1 -d" "`
>
> DATE=`date`


usual first time cron job error is that the PATH environment variable
is not set.

Check it for yourself

try this
/bin/env > /tmp/env.list
and see what is in /tmp/env.list

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
samba doesn't change modification dates? dterrors@hotmail.com Linux Networking 0 10-17-2007 06:14 AM
passphrase change doesn't save Jeff Wireless Networks 1 01-19-2006 11:09 PM
I can't operate crontab jwhan Linux Networking 4 07-05-2004 06:22 AM
computer doesn't detect connection Joe Edwards Windows Networking 7 12-29-2003 06:20 PM
executing webalizer from crontab Allan Bruce Linux Networking 1 11-20-2003 03:10 PM



1 2 3 4 5 6 7 8 9 10 11