Does anybody has a bash script or a solution for auto server start?
My server crashes sometimes those aren’t frequent crashes maybe like 2 crashes per month. But sometimes i am out of house and i have to restart it manually. I was thinking about making a bash script to check if it runs but i dont really know how to write it.
I normally recommend utilities known as forever and forever-service.
Check out Any script I try running at startup does not work and the links in that post.
You misunderstood me. I use forever for my scripts, but the blynk server itself which work on Java sometimes crashes. I dont think i can use forever to check if java process works.
As per the GitHub for the forever-service (not forever) https://github.com/zapty/forever-service java programs can be run as a service. The example it gives on the front page for the repository is:
$ sudo forever-service install javaservice1 -s start.jar -f " -c 'java -Xms1024m -Xmx1024m -jar'"
If already implemented a similar check with crontab, would you still recommend switching to forever-service?
I made a couple shell scripts and created cron schedules; one to download the latest server if it detects an update - runs it once everyday and another one to restart the server if not running (by checking ps) - runs it once every minute
Here is my take on it
I am a big fan of Monit.
Monit can check the state of any service using a variety of methods (even a shell script which could perform a Blynk connect, for example) and restart it if the check fails.