AKB48
March 9, 2012, 7:29am
1
hi, everyone.
My want to execute the shell script below per 10 seconds
PID=`pgrep java`
if [ $PID == "" ]
then
/home/java/java
fi
crontab wouldn't help me.
some one can give me suggestions?thanks
---------- Post updated at 07:29 AM ---------- Previous update was at 07:26 AM ----------
a mistake in title
not 10 mins,
it's 10 seconds
vbe
March 9, 2012, 7:43am
2
Use a while loop with a sleep of 10...
1 Like
methyl
March 9, 2012, 7:43am
3
Are you sure?
Please post what Operating System and version you have and what Shell you are using.
Also, please post what problem you are trying to solve.
1 Like
AKB48
March 9, 2012, 7:53am
4
in partitular,plz
i am newbie
---------- Post updated at 07:53 AM ---------- Previous update was at 07:48 AM ----------
RHEL 6.2
may be bash...
sorry, i'm newbie.i just want to execute the script i post per 10 seconds
the precision of crontab can make it run just per minute .
methyl
March 9, 2012, 7:59am
5
Consider what would happen if you had the following 6 crons:
/path_to_script/scriptname
sleep 10;/path_to_script/scriptname
sleep 20;/path_to_script/scriptname
sleep 30;/path_to_script/scriptname
sleep 40;/path_to_script/scriptname
sleep 50;/path_to_script/scriptname
However I do wonder if what you are attempting to do is at all sensible.
What problem with java are you attempting to solve?
1 Like
AKB48
March 9, 2012, 8:06am
6
methyl:
Consider what would happen if you had the following 6 crons:
/path_to_script/scriptname
sleep 10;/path_to_script/scriptname
sleep 20;/path_to_script/scriptname
sleep 30;/path_to_script/scriptname
sleep 40;/path_to_script/scriptname
sleep 50;/path_to_script/scriptname
However I do wonder if what you are attempting to do is at all sensible.
What problem with java are you attempting to solve?
thanks. i think it's okey.
i just want to do some test with java.
drl
March 9, 2012, 8:15am
7
Hi.
There is more than one way to interpret your question; methyl and vbe have one, here's another:
SYNOPSIS
timeout [OPTION] NUMBER[SUFFIX] COMMAND [ARG]...
timeout [OPTION]
DESCRIPTION
Start COMMAND, and kill it if still running after NUMBER seconds. SUF-
FIX may be 's' for seconds (the default), 'm' for minutes, 'h' for
hours or 'd' for days.
-- excerpt from man timeout on CentOS release 6.2 (Final)
Note that it is usually more important to state the answer to:
Best wishes ... cheers, drl
1 Like