How the Sleep function will work?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How the Sleep function will work?
# 1  
Old 10-13-2011
Network How the Sleep function will work?

Hi All,

I am new to Unix , there i am facing one problem with sleep command. that is ..
in while loop i have defined sleep function ..

my condition is like this

Code:
while [ 1 -le 0 ]  #i knew this is infinite loop
do

sleep 200
echo "hello "

done

.

this condition will never become .. true .. so.. my Question is how long this sleep condition keep on checking every 2 mints.. like .. a day or two days.
or the sleep function keep on executing ?

please any one can suggest me

Thanks
Sree

Last edited by pludi; 10-13-2011 at 09:31 AM..
# 2  
Old 10-13-2011
First, don't bump your questions just because you want a fast answer. See Rule #4 (yes, the rules are mandatory)

Second, please use Code tags when posting code listings, command lines, ...
# 3  
Old 10-13-2011
Quote:
Originally Posted by mandlysreedhar
Hi All,

I am new to Unix , there i am facing one problem with sleep command. that is ..
in while loop i have defined sleep function ..

my condition is like this

Code:
while [ 1 -le 0 ]  #i knew this is infinite loop
do
 
sleep 200
echo "hello "
 
done

.

this condition will never become .. true .. so.. my Question is how long this sleep condition keep on checking every 2 mints.. like .. a day or two days.
or the sleep function keep on executing ?

please any one can suggest me

Thanks
Sree
if you already know that it is an infinite loop ,then i think it makes no sense to ask this question .you can simply execute it on your machine..
# 4  
Old 10-13-2011
Not only do I not see an infinite loop anywhere, I see no loop at all. If the condition tested is always false, there won't even be a single iteration.

Regards,
Alister
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Doubt with signals and sleep function

Hi , I have a doubt with signals and sleep function. In a program i have this while(1) { //do some work sleep(1); }And in a thread i have something like this union sigval data; char message; char msg; data.sival_int=0; while(1) { ... (4 Replies)
Discussion started by: bacesado
4 Replies

2. Programming

Sleep function not detected

Hello Im using geany to write my c codes. Below is my code to make the internal LED of beaglebone flashing. But i cant seem to use the sleep or delay to make the program wait for a couple of miliseconds. I've included all include files that i can find but none of it solve the problem. Any help is... (1 Reply)
Discussion started by: HellRyder
1 Replies

3. UNIX for Dummies Questions & Answers

copy *. does not work in function

Hi, I want to copy a file/directory ( recursively , if needed) and if destination directory does not exist create it ( with parent directory, if needed). funcopy () { if ; then echo "$2 exists , copying files" cp -r "$1" "$2" else echo "Directory does not exist;Create directory" mkdir... (1 Reply)
Discussion started by: greet_sed
1 Replies

4. Programming

C Sleep function hangs @ __kernel_vsyscall ()

This is the gdb backtrace. ^C Program received signal SIGINT, Interrupt. 0xffffe424 in __kernel_vsyscall () (gdb) bt #0 0xffffe424 in __kernel_vsyscall () #1 0xb7e56a70 in __nanosleep_nocancel () from /lib/libc.so.6 #2 0xb7e568bb in __sleep (seconds=0) at sleep.c:138 #3 0x080496d5 in... (6 Replies)
Discussion started by: dragonpoint
6 Replies

5. Shell Programming and Scripting

Help with sleep function

Hey everyone, just entering the linux world, I need some help with a shell script i'm trying to write, the purpose is to check every 10 minutes what was the last time a certain file was modified, and if there is a connection to the server at this moment send an email with the date of the... (2 Replies)
Discussion started by: moshe88
2 Replies

6. Shell Programming and Scripting

Wrapping 'sleep' with my 'resleep' function (Resettable sleep)

This is a very crude attempt in Bash at something that I needed but didn't seem to find in the 'sleep' command. However, I would like to be able to do it without the need for the temp file. Please go easy on me if this is already possible in some other way: How many times have you used the... (5 Replies)
Discussion started by: deckard
5 Replies

7. UNIX for Dummies Questions & Answers

sleep 10 && command doesn't work

Hi there, I found a trick to easily postpone a command by a few seconds: supernova:~# sleep 10 && command &If you logout, the command should still be executed... But not all the time. Could anyone of you explain me why the following command is executed even after logging out: supernova:~# sleep... (2 Replies)
Discussion started by: chebarbudo
2 Replies

8. Web Development

work with date function

hi, how can i can pass the value of unixformat to date/time? and how can i retrieve the day/month/year from a date? thanks a lot for your help ps:i using php (1 Reply)
Discussion started by: jasonx22
1 Replies

9. UNIX for Dummies Questions & Answers

how does sleep work internally?

hi can someone explain how the sleep() function actually works, like where is it defined, wat files does it refer etc...? (1 Reply)
Discussion started by: meetbhattu
1 Replies

10. Shell Programming and Scripting

Will the continue function work ????

I have written a script which does a following functions:- 1) Check a area if it is mounted or not 2) If the area is not mounted it will prompt the user to mount the are. 3) Once the area is mounted and the option is given as Y or y the script continues... My question is will the below... (2 Replies)
Discussion started by: kamlesh_p
2 Replies
Login or Register to Ask a Question