#!/bin/bash
#I am just like a system daemon...
#I do not need nohup for work, and I should not be called from cron.
#My name is main_safe
#I will become a separeted process even if my father dies...
#i will check if main is still alive, and if dies i will restart it
#nohup is not needed inside shell script.
#IMPORTANT: to die is very different from to freeze
main_safe(){
trap "" HUP
while sleep 120; do
main&
wait
done
}
#My name is main I like to keep restarting php master.php
#everytime it go away... remove wait and I will keep starting master.php with absolutely no reason.
#If you are paranoid you can program me to restart main_safe,
#But what will happen if you try to stop me? Bad things.. so...
#IMPORTANT: to die is very different from to freeze
main(){
trap "" HUP
while sleep 60; do
php master.php &
#do whatever you want here
#uncomment this to prevent two instances of master.php from going up maybe it is necessary:
wait
done
}
#nohup is not needed in shell script
main_safe&
pstree -p | grep $!
Isso é aceitável?