Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Scheduling a task to run after 5 seconds

Posted on 2003-03-04
4
Medium Priority
?
209 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
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

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

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

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
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 Month11 days, 21 hours left to enroll

564 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