execute the shell script per ten seconds


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting execute the shell script per ten seconds
# 1  
Old 03-09-2012
Bug execute the shell script per ten seconds

hi, everyone.
My want to execute the shell script below per 10 seconds

Code:
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

Last edited by pludi; 03-09-2012 at 08:29 AM.. Reason: some mistake in post
# 2  
Old 03-09-2012
Use a while loop with a sleep of 10...
This User Gave Thanks to vbe For This Post:
# 3  
Old 03-09-2012
Quote:
crontab wouldn't help me.
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.
This User Gave Thanks to methyl For This Post:
# 4  
Old 03-09-2012
in partitular,plz
i am newbie

---------- Post updated at 07:53 AM ---------- Previous update was at 07:48 AM ----------

Quote:
Originally Posted by methyl
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.
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 .
# 5  
Old 03-09-2012
Consider what would happen if you had the following 6 crons:
Code:
/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?
This User Gave Thanks to methyl For This Post:
# 6  
Old 03-09-2012
Quote:
Originally Posted by methyl
Consider what would happen if you had the following 6 crons:
Code:
/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.
# 7  
Old 03-09-2012
Hi.

There is more than one way to interpret your question; methyl and vbe have one, here's another:
Code:
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:
Quote:
What problem .. are you attempting to solve?
Best wishes ... cheers, drl
This User Gave Thanks to drl For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Batch script to execute shell script in UNIX server

Hi team, My requirement is to transfer pdf files from windows machine to unix server and then from that unix server we should sftp to another server. I have completed the first part i.e From windows to using to unix server with the help of psftp.exe code: psftp user@host -pw password <... (1 Reply)
Discussion started by: bhupeshchavan
1 Replies

2. Shell Programming and Scripting

How to exit a shell script if a unix command does not return any value for 10 seconds?

Hi, Can anyone help me how to exit a shell script if a unix command inside does not return any value for 10 seconds? The scenarios is like this. I want to login to a application using shell script where the connection string is mentioned.but suppose this connection string is not... (10 Replies)
Discussion started by: arijitsaha
10 Replies

3. Shell Programming and Scripting

Dos batch script to execute unix shell script

Can anyone help me with a dos batch script to execute a shell script residing in an unix server. I am not able to use ssh. Thanks in advance (2 Replies)
Discussion started by: Shri123
2 Replies

4. Shell Programming and Scripting

How to use ssh execute other shell script on other host (shell script include nohup)?

i want use ssh on the host01 to execute autoexec.sh on the host02 like following : host01> ssh host02 autoexec.sh autoexec.sh include nohup command like follwing : nohup /home/jack/deletedata.sh & after i execute ssh host02 autoexec.sh one the host01. i can't found deletedata.sh... (1 Reply)
Discussion started by: orablue
1 Replies

5. Shell Programming and Scripting

Execute unix shell script to text file using the script

Hi all, I am beginner in UNIX...I want to use unix shell script to create text.file...I know how to use using by command...can anybody tell me for the script? Thanks i changed the threads title from "tex file" to "text file", because "tex" would probably be misunderstood as reference to... (4 Replies)
Discussion started by: mastercar
4 Replies

6. Shell Programming and Scripting

Retry every ten seconds while lockfile present

Hi, I have written below check lockfile script but need some tweaking on it. If there is a lockfile from present, I need the script to retry every 10 seconds to see if the lockfile is still there. After 120 seconds it should send an email. In my current version, if the script encounters... (6 Replies)
Discussion started by: Meert
6 Replies

7. Shell Programming and Scripting

shell script that will automatically check if specifed user is log in or not, in 30 seconds

guys I need emergency help with below shell script assignment..am new to shell script Write a Shell script to automatically check that a specified user is logged in to the computer. The program should allow the person running the script to specify the name of the user to be checked, the... (2 Replies)
Discussion started by: gurmad
2 Replies

8. Shell Programming and Scripting

shell script to auto process ten random files and generate logs

Hello member's I'm learning to script in the ksh environment on a Solaris Box. I have 10 files in a directory that I need to pass, as input to a batch job one by one. lets say, the files are named as follows: abcd.txt ; efgh.bat ; wxyz.temp etc. (random filenames with varied extensions ).... (1 Reply)
Discussion started by: novice82
1 Replies

9. UNIX for Dummies Questions & Answers

Unix shell script for finding top ten files of maximum size

I need to write a Unix shell script which will list top 10 files in a directory tree on basis of size. i.e. first file should be the biggest in the whole directory and all its sub directories. Please suggest any ideas (10 Replies)
Discussion started by: abhilashnair
10 Replies

10. Shell Programming and Scripting

wait for 5 seconds in shell script

hi how can i wait for 5 seconds inside my shell script? 'wait 5' command doesnot seem to be working? (2 Replies)
Discussion started by: gopsman
2 Replies
Login or Register to Ask a Question