#!/bin/bash service_name="2336" while true; do if [[ $(ps -ef | grep -v grep | grep "$service_name" | wc -l) -gt 0 ]]; then echo "Service $service_name is already running." else echo "Service $service_name is not running. Restarting..." python ./api.py fi sleep 5 done