Skip to content
Snippets Groups Projects
Commit ccf8bd98 authored by Timothe Jost's avatar Timothe Jost
Browse files

better cronjob.sh

parent 52638e1d
No related branches found
No related tags found
No related merge requests found
...@@ -21,23 +21,6 @@ start_task() { ...@@ -21,23 +21,6 @@ start_task() {
echo $! > "$PIDFILE" echo $! > "$PIDFILE"
} }
# # Check if the PID file exists
# if [ -f "$PIDFILE" ]; then
# PID=$(cat "$PIDFILE")
# # Check if the process is running
# if ps -p $PID > /dev/null; then
# echo "Task is already running with PID $PID" >> "$LOGFILE"
# exit 0
# else
# echo "Task is not running, but PID file exists. Cleaning up..." >> "$LOGFILE"
# rm -f "$PIDFILE"
# fi
# fi
# # Start the task
# start_task
# sleep 10
# Monitor the task and restart if it crashes # Monitor the task and restart if it crashes
while true; do while true; do
PID=$(cat "$PIDFILE") PID=$(cat "$PIDFILE")
...@@ -45,5 +28,6 @@ while true; do ...@@ -45,5 +28,6 @@ while true; do
echo "Task crashed. Restarting..." >> "$LOGFILE" echo "Task crashed. Restarting..." >> "$LOGFILE"
start_task start_task
fi fi
echo "Restarting task in $SLEEP_TIME seconds..." >> "$LOGFILE"
sleep $SLEEP_TIME sleep $SLEEP_TIME
done done
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment