LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   want to run program every minute, crontab???? (https://www.linuxquestions.org/questions/linux-general-1/want-to-run-program-every-minute-crontab-364947/)

poj 09-19-2005 01:32 PM

want to run program every minute, crontab????
 
I have a java program that talk to database. I want this program to run every minute. I plan to use crontab but worry about the new job will start when the old one is not finish. Should I use crontab for this case? Anyway to make sure that only one process running on system?

david_ross 09-19-2005 01:36 PM

The easiest way would just be to loop one proccess with a pause after it completes each task.

If you want to launch a new proccess each time then using a check file would probably be sufficient.

poj 09-19-2005 01:42 PM

Quote:

Originally posted by david_ross
If you want to launch a new proccess each time then using a check file would probably be sufficient.
how to using a check file with crontab? you mean create a file when start process and delete it at the end of process?

david_ross 09-19-2005 01:59 PM

Quote:

Originally posted by poj
you mean create a file when start process and delete it at the end of process?
Yes, obviously check that it doesn't already exist before creating it. If it does exist then you can either loop until it is deleted or just exit.

Vgui 09-19-2005 04:29 PM

As usual, scripting is the answer. You could throw your java start command in a for loop, sleep in between for a bit, and reloop if the last one is done. Sort of like:
Code:

for infinite (or maybe time limit)
java && sleep 1000

That way the java program will finish executing, then a sleep will happen. You could also do "java ; sleep 1000", to make sure the sleep always happens, even if the java program gives an unusual exit signal.


All times are GMT -5. The time now is 07:29 PM.