Timed Script
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? Ridler :Pengy: :scratch: |
Something like this maybe:
#!/bin/bash # do all the setup stuff you need to do sleep 5 # slept 5 seconds, run IP check ipcheck whatever # 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 |
Will this continue to loop?
Ridler :scratch: |
Yes it will. It will abort on error.
|
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. What needs to be done now? Ridler :scratch: |
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? Ridler :scratch: |
Like I mentioned before: call it from /etc/crontab
See "man cron" and "man crontab". |
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. |
Quote:
Code:
nohup script_file.sh >/dev/null 2>&1& Quote:
|
I have used "crontab" and it does seem to be working, but it needs to run for the first time 5 - 10 seconds after startup too.
ipcheck.sh or nohup ipcheck.sh >/dev/null 2>&1& I am not sure I am following the process correctly. Ridler :scratch: |
All times are GMT -5. The time now is 02:06 PM. |