LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-10-2006, 11:12 AM   #1
alanvee
LQ Newbie
 
Registered: Jan 2006
Posts: 7

Rep: Reputation: 0
script execution: startup & cron


I'm trying to get a script which will update my ip for dynamic IP to run hourly and at startup. This is on a new install of Fedora Core4.

I'm using ipcheck.py and have a version living in /var/ipchk, a directory I created just for this task.
The script-file is named ip-update and contains this:

#!/bin/bash
python /var/ipchk/zoneck.py -l -c --VT1000v areinhart 1q2w3e4r reswebdev.com

where "zoneck.py" is my (only slightly) edited version of ipcheck.py.

When I run it from the keyboard it runs fine and the log file it creates has the current time set.

I have a symbolic link to ip-update in /etc/rc.d/rc5.d plus one in /etc/cron.hourly.

On restart or on the hour there is no change to the timestamp of the logfile in /var/ipchk so I'm assuming it is not running on those events. The permisssions for ivarp/chk and the key files are 775, and the owwner and group is root.

This has to be dog-simple! Where am I going astray??

=Alan R.
 
Old 02-10-2006, 12:26 PM   #2
fuzzyash
Member
 
Registered: Aug 2003
Location: Melbourne Australia
Distribution: Fedora Core 4
Posts: 184

Rep: Reputation: 30
I am curious as to why you would want to update your IP every hour. Once you have been assigned an IP number you shouldn't need to change it until you next fire up which ever network connection gets it's IP dynamically, shouldn't you?

What does ipcheck.py do for you? Does it simply get your current assigned IP number & log it or does it request a new IP number?

Anyway, check out http://wikiserver.freenethelp.org:14...StartGuideUnix & scroll down to where it says ipAddress. It talks about an app called DDclient, maybe this might be useful to you.
 
Old 02-10-2006, 01:20 PM   #3
alanvee
LQ Newbie
 
Registered: Jan 2006
Posts: 7

Original Poster
Rep: Reputation: 0
Not a DNS or IP issue!

This is for the WAN IP on a office network. The local machines ( all 3!) are all on a private network and are statically assigned.

I have a domain name but have a dynamic IP adderess assigned by Comcast. The lease on this runs out periodically and I never know when that will happen. So ipcheck looks at the router to see if the WAN address has changed, and if so, the DNS hosting (look for zoneedit - I can't post real URLS here!) gets notified and my entry gets updated. This all my clients can get to my devlopment server to check their site even tho the IP for that name changes.

So my issue here has nothing to do with DNS in general but how to get a script to excute at startup time and as a cron job.

Tks!

=Alan R.
 
Old 02-17-2006, 01:49 PM   #4
fuzzyash
Member
 
Registered: Aug 2003
Location: Melbourne Australia
Distribution: Fedora Core 4
Posts: 184

Rep: Reputation: 30
Oh! If I am understanding you correctly, all you want is for a script, which could be any script, to run at startup & once every hour! This is easy!

Your first problem is getting it run at boot. To use the /etc/rc.d files, known as the SysV system, the script that gets run needs to have a particular format. You would use this method if you need it to run at a particular part of the boot sequence, like before the firewall but after the network is up. Also this method gives you a pretty / professional way of running a script at boot for it can produce a nice "Passed / Failed" line to be displayed at it's particular part of the boot sequence which can be handy if you need to know if the script was successfully, like what you see when you click the "Show Details" button on the Fedora boot screen. I can take you thru it if you would like to go to this much trouble, or if you are simply curious & would like to know how it's done.
There is, however, a much simpler way of getting this script to run, the only thing is that it won't be run until all the system stuff has finished, which I don't think should be a problem for you. Simply add the script name to a new line in the file :

/etc/rc.d/rc.local

This file is specifically for running user designated scripts at boot.

The following is an example of my /etc/rc.d/rc.local file with your script added at the bottom :

Code:
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local

# i2C adapter drivers
modprobe i2c-i801
modprobe i2c-isa
# I2C chip drivers
modprobe lm75
modprobe eeprom
modprobe w83627hf
sleep 2 # optional
/usr/bin/sensors -s # recommended

# Fix for mplayer
echo 1024 > /proc/sys/dev/rtc/max-user-freq

# /sbin/modprobe nvidia

ip-update
Your file will, of course, look rather different than this. If you are still unsure, post your /etc/rc.d/rc.local file & I'll show you.

As for your cron job to run it every hour, how are you trying to achieve this currently? If you haven't already, you need to add a cron job via crontab. I find it's easier to edit in gedit, execute the following to make gedit your default crontab editor :

From a terminal, "su -" to root & open the file :

/etc/profile

Add the line :

Code:
VISUAL=gedit
just above the following line :

Code:
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC
& add "VISUAL" to the end of the above line, should look something like :

Code:
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC VISUAL
Finally, save & close the file.

To activate this change you need to go back to the terminal, logout from root with " <CTRL> d " & log back in again with " su - ".

Now run :

Code:
crontab -e
This will open roots crontab file for editing.

Check out :

http://enterprise.linux.com/article..../08/10/1948233

for a brief tutorial on the syntax of the crontab file.

Basically, the line that you will want to add to your crontab file should look like :

Code:
0 * * * * ip-update
Save the file & close it. You should get a message that says :

Code:
crontab: installing new crontab
This should now run your script every time you boot & then once every hour, on the hour.

If you have any problems let me know & I'll help you solve them. Otherwise if all goes smoothly then please post one last time to let me this.

Good Luck!
 
  


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
shell script using /etc/cron.hourly to execute cron.php file? rioguia Programming 3 06-11-2008 08:09 AM
bash script & cron probs. skubik Programming 17 10-16-2005 02:00 PM
program execution at startup DeeDub Linux - Software 2 09-11-2003 01:25 PM
randomizing execution of some cron entries markus1982 Linux - General 2 06-28-2003 09:49 AM
Stopping before the Execution of the startup files !! sachin77 Linux - Newbie 0 04-25-2001 03:23 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:21 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