How to run shell script in every 15 seconds

| May 13, 2011

The smallest granularity of cron is 1 minute. In order for something to run more often, you need to control it in the script.

How long does the 05-1.txt take to run (BTW, that’s a very unusual name for a shell script)

What you can do is create a controlling script continuously runs and fires off the script every 15 seconds, eg:

#!/bin/sh
while true
do
/bin/sh /var/www/xxxvhosts/100at.com/httpdocs/05-1.txt &
sleep 15
done

Note, that you’ll start to get into problems if 05-1.txt takes longer than 15 seconds to run.

Alternatively, you could just run it one after another, eg:

#!/bin/sh
while true
do
/bin/sh /var/www/xxxvhosts/100at.com/httpdocs/05-1.txt
sleep 10 # Either keep this in here or comment it out.
done

Tags: ,

Category: Linux Administration

Comments are closed.