mardi 24 mars 2015

crontab is launching multiple java process every 5 minutes?


I have a java runnable jar which I need to run it if it not running or got killed for some reason so I decided to use crontab for this -


I need to run the crontab as "poppetapp" user so I am logged in as this user and created crontab like this -



*/5 * * * * pgrep -f test_java_10.jar || cd /home/poppetapp && /home/poppetapp/test_java.sh > /home/poppetapp/test_java.out


And my shell script is like this which is in /home/poppetapp/ location -



#!/bin/sh
/usr/home/java -jar /home/poppetapp/test_java_10.jar


My java runnable jar is in the home location for "poppetapp" user which is /home/poppetapp/.


So my question is - Does this look right? I just need to start my test_java.jar if it is not running or got killed for some reason so I created a crontab which will run every 5 minutes to check whether it is running or not. If it is not running it will execute my shell script to start the test_java.jar process.


But somehow when I make this crontab change, I am seeing lot of test_java.jar process is getting invoked. I think every 5 minutes it is launching another process for this.



Aucun commentaire:

Enregistrer un commentaire