run process (Java/Shell) every 10 minutes

N

N.K.

Hi,
I need to run a shell script or a java app every 10 minutes for
several hours starting at the specified time and ending at the
specified time.
I can schedule a cron job for it but it would be about 40 to 50
crontab entries and I don't know if that is just stupid to do and if
there is a better way to do it.
I was wondering if I can write some kind of a deamon process or a java
server process. Should I use Server Socket?
I have a Fedora Core 1 as a platform.

Thanks in advance
NK
 
P

Paul Lutus

N.K. said:
Hi,
I need to run a shell script or a java app every 10 minutes for
several hours starting at the specified time and ending at the
specified time.
I can schedule a cron job for it but it would be about 40 to 50
crontab entries and I don't know if that is just stupid to do and if
there is a better way to do it.
I was wondering if I can write some kind of a deamon process or a java
server process. Should I use Server Socket?
I have a Fedora Core 1 as a platform.

Why is this posted in Java newsgroups? Obviously Java can do this, but it is
is not the appropriate way to create a daemon and run periodic system
tasks.

Create a shell script to run your task in the range of specified times, put
it in the background, end of story. Not tested, just a concept:

#!/bin/sh

while true
do
d=$(date +%H%M)
if [ "$d" -ge "1215" -a "$d" -lt "1546" ]
then
# do something here
fi
sleep 36000 # ten minutes
done
 
S

shakahshakah

You might not need "40 to 50 crontab entries", just something like:
0,10,20,30,40,50 7,8,9 * * * /path/to/your/shell-script

Or you can have a single cron entry that launches a shell script at the
start time and loops until the end-time (which you pass in as an arg,
-e for "end"?):
0 7 * * * /path/to/your/shell-script -e "10:00:00"

Or do the same with a Java class, for that matter:
0 7 * * * /usr/bin/java -classpath "your class path"
com.parkerglobal.nkapp -e "10:00:00"
 
M

Mike H

I believe linux allows for division and ranges....

60/10 7-9 * * * /your/script/run ever 10min from 7am to 9am..
 
T

Thomas Weidenfeller

N.K. said:
I can schedule a cron job for it but it would be about 40 to 50
crontab entries and I don't know if that is just stupid to do and if
there is a better way to do it.

I suggest you study the crontab man page intensively. Unless you haven't
told us all timing requirements one single crontab entry will do.

BTW: Consider posting Unix/Linux questions to Unix/Linux newsgroups next
time.

/Thomas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top