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. |
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. |
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. |
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 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 Code:
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC Code:
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC VISUAL 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 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 Code:
crontab: installing new crontab 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! |
All times are GMT -5. The time now is 06:47 AM. |