Observation1
logic.sh
#!/bin/bash
#get system metrics
#do stuff and echo it
echo "put metrics" | nc $ip $port
echo "Metrics $metrics"
run_logic.sh
#!/bin/bash
while true;do
sh logic.sh >> test.log 2>&1 &
sleep 60
done
start_logic.sh
#!/bin/bash
case $1 in
start)
#start the run_logic.sh
;;
stop)
#stop the run_logic.sh
;;
*)
echo "Invalid Option!"
exit 1
esac
exit0
Observation2
logic.sh
#!bin/bash
while true;do
#do stuff and echo it
#get System Metrics and put it
echo $stuff
sleep 60
done
start_logic.sh
#!/bin/bash
case $1 in
start)
#do some stuff, check already started or not
sh logic.sh >> test.log 2>&1 &
;;
stop)
#do some stuff
#Kill the process
;;
*)
echo "Invalid Option!"
exit 1
esac
exit0
Now!, In observation1, the scripts are dying in middle of execution. I checked the logs, but I didn't see any error messages. In observation2, the scripts works fine(99% fine!). So, what is difference observation1 and observation2, why scripts are dying in the first case?