• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Problem Running sh script on the background

crowd

Lurker
Hello,
I wrote some sh script to my device which has to run for a long period of time.
I wanted to run the script on the background so i run the script with "&" but for some reason the script freeze whenever the device is getting into standby mode.

I made some testing script (called testcode.sh) which simply count seconds to see what happen

Code:
#!/system/bin/sh
i=0
while (); do
sleep 1
i=$((i+1))
echo -e "\n\rIt has been $i sec since the script started"
done

I run the script from a terminal (./testcode.sh &) and saw the counter start counting, i then put the device to standby mode (short press on the power button) and waited for 10 min. after 10 min i open the device and saw that the counter still counts but the time was 3 min (180 sec).

So i guess the script kept running for 3 min then hang for some reason and resume when the device got off standby mode.

Is there a way to make my script keep on runnning ?
 
Back
Top Bottom