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
So my question is - Does this look right? I just need to start my
test_java_10.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
But somehow when I make this crontab change, I am seeing lot of
test_java_10.jar process is getting invoked. I think every 5 minutes it is launching another process for this.
If I modify my crontab like this -
*/5 * * * * pgrep -f test_java_10.jar || /home/poppetapp/test_java.sh > /home/poppetapp/test_java.out
then I see below mail which doesn't say what's the problem or does it say anything?
& t 35 Message 35: From poppetapp@machineA Tue Mar 24 17:05:01 2015 X-Original-To: poppetapp From: root@machineA (Cron Daemon) To: poppetapp@machineA Subject: Cron <poppetapp@machineA> pgrep -f test_java_10.jar || /home/poppetapp/test_java.sh > /home/poppetapp/test_java.out Content-Type: text/plain; charset=ANSI_X3.4-1968 X-Cron-Env: <SHELL=/bin/sh> X-Cron-Env: <HOME=/home/poppetapp> X-Cron-Env: <PATH=/usr/bin:/bin> X-Cron-Env: <LOGNAME=poppetapp> Date: Tue, 24 Mar 2015 17:05:01 -0700 (GMT+7)