?
Solved

Scheduling a task to run after 5 seconds

Posted on 2003-03-04
4
Medium Priority
?
207 Views
Last Modified: 2010-04-20
I want to schedule a linux shell script to run after every 5 seconds. The crontab has features only for setting it in minutes and ktimer is GUI based but I want to use command line interace and let it run as a background job till the system restarts.
 And please also tell me how to make a job to restart automatically whenever the system restarts. Waiting for ur cool help. Thanx in advance.
0
Comment
Question by:redhat_786
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 2

Accepted Solution

by:
jimbb earned 200 total points
ID: 8070458
Make a shell script something like this:

#!/bin/sh

while : ; do
    /your/script/here
    sleep 5
done

(If your own script does not exit right away you will want to background it by putting a '&' at the end of the line.)


In order to make it start at boot, you can either put it in /etc/rc.local, or make a crontab entry for it -- and instead of putting the usual 5 date/time specifiers, use "@reboot" (this is documented in the crontab man page of my BSD box, doesn't seem to be mentioned in my RHL man page but I believe it will still work).

Note: the above script is untested, but it's simple enough.  I'm half asleep as I write this though so make sure to test it before relying on it. ;)
0
 
LVL 18

Expert Comment

by:liddler
ID: 8072453
you might also want to put it in /etc/inittab, with the respawn option, so that it will restart if it crashes / is killed
0
 

Expert Comment

by:CleanupPing
ID: 9087787
redhat_786:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 2

Expert Comment

by:TheWeakestLink
ID: 9286879
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Accept comments from jimbb as answer
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

TheWeakestLink
EE Cleanup Volunteer
0

Featured Post

Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses
Course of the Month13 days, 13 hours left to enroll

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question