LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-28-2004, 11:58 PM   #1
rridler
Member
 
Registered: Apr 2004
Location: N. Kentucky
Distribution: Fedora 13 and Fedora 14
Posts: 46

Rep: Reputation: 15
Question 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


Last edited by rridler; 06-28-2004 at 11:59 PM.
 
Old 06-29-2004, 12:43 AM   #2
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
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
 
Old 06-29-2004, 02:22 PM   #3
rridler
Member
 
Registered: Apr 2004
Location: N. Kentucky
Distribution: Fedora 13 and Fedora 14
Posts: 46

Original Poster
Rep: Reputation: 15
Will this continue to loop?

Ridler
 
Old 06-29-2004, 03:07 PM   #4
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 36
Yes it will. It will abort on error.
 
Old 06-30-2004, 01:08 AM   #5
rridler
Member
 
Registered: Apr 2004
Location: N. Kentucky
Distribution: Fedora 13 and Fedora 14
Posts: 46

Original Poster
Rep: Reputation: 15
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
 
Old 06-30-2004, 11:55 AM   #6
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
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.
 
Old 06-30-2004, 02:35 PM   #7
rridler
Member
 
Registered: Apr 2004
Location: N. Kentucky
Distribution: Fedora 13 and Fedora 14
Posts: 46

Original Poster
Rep: Reputation: 15
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
 
Old 07-01-2004, 07:31 AM   #8
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Like I mentioned before: call it from /etc/crontab
See "man cron" and "man crontab".
 
Old 07-01-2004, 09:09 AM   #9
cck23
Member
 
Registered: Jun 2004
Location: Surrey, UK
Distribution: Mandrake 10 Download
Posts: 73

Rep: Reputation: 16
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.
 
Old 07-01-2004, 06:29 PM   #10
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Quote:
Hko's suggestion should work but you could also run the script with the command:

script_file.sh & (note: & at the end)
That's true. Maybe even better:
Code:
nohup script_file.sh >/dev/null 2>&1&
Quote:
cron is better as something could kill your background process accidentally, make your choice.
I think my suggestion with "nohup" will also prevent that. Myself I'd still prefer the cron way though.
 
Old 07-01-2004, 10:52 PM   #11
rridler
Member
 
Registered: Apr 2004
Location: N. Kentucky
Distribution: Fedora 13 and Fedora 14
Posts: 46

Original Poster
Rep: Reputation: 15
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

Last edited by rridler; 07-01-2004 at 11:02 PM.
 
  


Reply



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
Timed suspend.. Alex_jacobson Slackware 3 04-15-2005 09:23 PM
Timed actions LongName Programming 2 09-02-2004 03:42 AM
simple timed shutdown script lin00b Linux - Newbie 4 07-17-2004 09:19 PM
timed backups dennis_89 Linux - Networking 2 06-17-2004 09:55 AM
KPPP modem script timed-out kulangotx Linux - Software 2 02-07-2004 07:23 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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