ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have a little problem.
I need to run an ipcheck script 5 - 10 seconds after all other operations are done and the firewall script has run.
Also, it needs to be run every 20 minutes or so to keep my dynamic host IP address updated. This at the suggestion of my ISP. They have a very short lease on the IP that they assign.
Anyone have a way to do this?
# now run every 20 minutes more or less -- this isn't exact thanks to
# the vagarities of kernel scheduling, but it should be close enough
while true
do
ipcheck whatever
sleep 20*60 # 20 minutes
done
I created the script like you outlined and it loops like I want it to, but I ran into a problem.
It will not give the OS control of the computer, it stays in a continous loop of the script and never completes the boot process.
Another solution:
Have you firewall script touch /tmp/__my_firewall (yes, in /tmp because when the system reboots it will be deleted usually). Than make the ipcheck-script test if /tmp/__my_firewall, and only if the file exists actually do the ip-check. Then put your script in /etc/crontab to have run every 20 minutes.
I do have a firewall script (fw3) and it is called from the /etc/rc.d/rc.local, it runs before the ipcheck script (ipcheck) also in the /etc/rc.d/rc.local.
Is there a better way to call this script, so that it loops and also allows complete booting of the OS?
Hko's suggestion should work but you could also run the script with the command:
script_file.sh & (note: & at the end)
The rc scripts will run it in the background and carry on with the rest of the boot process. But having said that, cron is better as something could kill your background process accidentally, make your choice.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.