I've a server nodejs server.js and I want it to restart as soon as  it crashes but only if previous restart time is more than a second. This will prevent my email being flooded if the server exits immediately.Here is the start_server.sh which restarts it. I've placed it in @reboot in crontab and it starts quite fine when the server boots.But how can I run start_server.sh from the terminal and close the terminal later and it should work just fine without exiting?I've tried nohup start_server.sh but that does not work. I also want to redirect the STDOUT to a log file.start_server.sh#!/bin/shset -xcount=0while :doif test $count -lt 40thenmail -s server.js started just now myemail@gmail.com  < /dev/nullficount=`expr $count + 1`date1=`date +%s`  #get unix timecd /home/login/railways/nodejsecho Starting time is $date1 /usr/bin/nodejs server.js >> server.logdate2=`date +%s`  #get unix timeif test $date1 -eq $date2then        msg=exiting as process has failed        echo $msg        if test $count -lt 40        then        mail -s $msg  myemail@gmail.com  < /dev/null        fi        sleep 10fiecho restarting the processsleep 1done
Start server from terminal using a script
ubuntu