1.

Solve : unix sleep and date commands?

Answer»

please help me to fix my script trying to use sleep 2 minutes while the system is sleeping i want to PRINT out same message every 5 seconds
thanks
t=`date +%S`

while [ t = t+120 ]
do
sleep 5

echo "this program will end in 2 minute"
done


I don't know if you can make a computer do anything while it is sleeping. It usually pauses all PROCESSES so it can ENTER a low POWER state.
You're not trying to create a screensaver are you?It's not that kind of sleeping michaewlewis... its a sleep command in a script.
I.e. he wants the script to pause for a SET time.

fanco it would probably help with some more details... including what kind of scripting language you're using.Quote from: fanco on October 04, 2007, 10:12:39 AM

please help me to fix my script trying to use sleep 2 minutes while the system is sleeping i want to print out same message every 5 seconds
thanks
t=`date +%S`

while [ t = t+120 ]
do
sleep 5

echo "this program will end in 2 minute"
done




Code: [Select]t=$(date +%S)
t=`echo $t+120 |bc`
echo "this program will end in 2 minutes from now"
sleep $t
exit


Discussion

No Comment Found