yugecin / tsstats

Bot for teamspeak3 to collect data for generating statistics
GNU General Public License v3.0
8 stars 4 forks source link

Cronscript (Question) #3

Closed Artapel closed 2 years ago

Artapel commented 7 years ago

Hi Guys

Does anyone have a cronjob script to make sure that check if the jar runs and if it does not. runs it again?

yugecin commented 7 years ago

This is (somewhat) the script that I use.

#!/bin/bash

PROCESS=$(ps -ef | grep -P '\-jar \/home\/pi\/tsstats\/tsstats\.jar' | head -1)
APP=$(echo $PROCESS | awk {'print $8'}) #you might need to edit the $8 to correspond to the column which has the command

if [ "$APP" != "/opt/jdk1.8.0/bin/java" ]; then
        cd /home/pi/tsstats
        mv out out2
        nohup /opt/jdk1.8.0/bin/java -jar /home/pi/tsstats/tsstats.jar 1>out 2>&1 &
fi

and this is my crontab entry 3 */6 * * * /home/pi/tsstats/tsstats.restart.sh&

Artapel commented 7 years ago

Thank you very much. Il try it out tonight.

Artapel commented 7 years ago

how do i find the correct string to use on the 1st line of the .sh this line "ps -ef | grep -P '-jar \/home\/pi\/tsstats\/tsstats.jar' | head -1"

yugecin commented 7 years ago

it's just the location where the jar is located

Artapel commented 7 years ago

Kwl.kwl thanks

On 09 Jul 2017 11:28 AM, yugecin notifications@github.com wrote:

it's just the location where the jar is located

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/yugecin/tsstats/issues/3#issuecomment-313909076, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ARY-lh8Q-5jfG9zsoxGWyD67U0-wUxqrks5sMJ1LgaJpZM4OQ3XB.

NOTE: This e-mail is intended solely for the use of the individual(s) to whom it is addressed. If you are not an intended recipient you must not use, disclose, distribute, copy, print, or rely on this e-mail.