1. Download our Official Android App: Forums for Android!

Apps Problem Running sh script on the background

Discussion in 'Android Development' started by crowd, Oct 17, 2011.

  1. crowd

    crowd Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    1
    Joined:
    Oct 17, 2011

    Oct 17, 2011
    1
    0
    5
    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 (Text):
    1.  
    2. #!/system/bin/sh
    3. i=0
    4. while (); do
    5. sleep 1
    6. i=$((i+1))
    7. echo -e "\n\rIt has been $i sec since the script started"
    8. done
    9.  
    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 ?
     

    Advertisement

Share This Page

Loading...