LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   Waking script from wait state (http://www.linuxquestions.org/questions/slackware-14/waking-script-from-wait-state-4175459357/)

waddles 04-23-2013 08:06 PM

Waking script from wait state
 
I have some shell script code where I would like to suspend, hibernate or put to sleep then on a condition have it wake up and continue. This point where I want to do this is within a designed infinite while loop which sleeps 1 second at the end of each loop. Ideally I would like to have the condition of a driver wake the slumbering code. The condition I am looking at is whether or not an interface ppp0, eth0, etc. is active.
Any suggestions for doing this? I could use "wait" to put it to sleep but haven't seen anything that could be used to wake it up like I want.

cortman 04-23-2013 08:28 PM

You want the "sleep" command- it pauses for whatever interval in seconds you specify, then goes on to the next command.

Code:

echo ready in 5... ; sleep 5 ; echo seconds!
As far as having it running, why not start it and send it to the background?

Code:

./myscript &

waddles 04-23-2013 08:54 PM

Waking script from wait state
 
Using "sleep" could miss an event so this is not useable here.
The same problem exists whether foreground or background.

speck 04-23-2013 09:20 PM

I don't know the method you're using to determine if the interface is active, but you might want to look at inotifywait to see if it would be useful.

cortman 04-23-2013 09:33 PM

Quote:

Originally Posted by waddles (Post 4937631)
Using "sleep" could miss an event so this is not useable here.
The same problem exists whether foreground or background.

My idea was that your script would *check* if the event requiring further action had occurred; i.e., according to the OP if interface eth0 was active; if eth0 was not active, the script would sleep for a second, then check again, and keep looping that way.
Maybe it'd be more helpful if you'd say what you're trying to do.


All times are GMT -5. The time now is 07:43 AM.