I've got a script that gets run during boot on a Debian server. It's getting run too early, but I can't control when it's fired off. I can force the script to delay its own run with:
sleep 60
...or, alternately, I could just try the action a few times, like this:
TESTRUN=0
ACTIONWORKED=0
while [ $ACTIONWORKED -eq 0 ] && [ $TESTRUN -le 5 ]; do
# run the action i want
# quick test if it worked
# if yes, set ACTIONWORKED=1
# if no, sleep 10
# increment TESTRUN
done
What's a better way to test that the system is ready? The script will be run at other times during system operation, so the test is needed to differentiate between "booting-can't-do-this-yet" and "not-booting-run-now" states. I don't want it to wait every time the script runs.
Edit: Thanks for the ideas so far. Keep 'em coming if you have alternatives to what's already been posted.
To those who've asked for specifics, I've left them out of the question specifically to gather answers that work with the general Linux boot process.
Assume a "fully booted" system has presented a login prompt (via console, X, or whatever).