Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

sleep(3) [debian man page]

SLEEP(3)						     Linux Programmer's Manual							  SLEEP(3)

NAME
sleep - sleep for the specified number of seconds SYNOPSIS
#include <unistd.h> unsigned int sleep(unsigned int seconds); DESCRIPTION
sleep() makes the calling thread sleep until seconds seconds have elapsed or a signal arrives which is not ignored. RETURN VALUE
Zero if the requested time has elapsed, or the number of seconds left to sleep, if the call was interrupted by a signal handler. CONFORMING TO
POSIX.1-2001. BUGS
sleep() may be implemented using SIGALRM; mixing calls to alarm(2) and sleep() is a bad idea. Using longjmp(3) from a signal handler or modifying the handling of SIGALRM while sleeping will cause undefined results. SEE ALSO
alarm(2), nanosleep(2), signal(2), signal(7) COLOPHON
This page is part of release 3.44 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. GNU
2010-02-03 SLEEP(3)

Check Out this Related Man Page

SLEEP(3)						     Linux Programmer's Manual							  SLEEP(3)

NAME
sleep - Sleep for the specified number of seconds SYNOPSIS
#include <unistd.h> unsigned int sleep(unsigned int seconds); DESCRIPTION
sleep() makes the calling thread sleep until seconds seconds have elapsed or a signal arrives which is not ignored. RETURN VALUE
Zero if the requested time has elapsed, or the number of seconds left to sleep, if the call was interrupted by a signal handler. CONFORMING TO
POSIX.1-2001. BUGS
sleep() may be implemented using SIGALRM; mixing calls to alarm(2) and sleep() is a bad idea. Using longjmp(3) from a signal handler or modifying the handling of SIGALRM while sleeping will cause undefined results. SEE ALSO
alarm(2), nanosleep(2), signal(2), signal(7) COLOPHON
This page is part of release 3.27 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. GNU
2010-02-03 SLEEP(3)
Man Page

14 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Time

I have a Solaris 2.6 machine and I execute the following: while do echo looping sleep 15 done I would assume the looping would be printed every 15 seconds but it doesn't. consecutive looping gets printed without a 15 second gap. Any idea what might be the reason ? Thanks (9 Replies)
Discussion started by: brv
9 Replies

2. Shell Programming and Scripting

Sleep under one second

If I want a script to sleep for less than a second, would I use a decimal? In other words, if I wanted my script to sleep for 1/4 of a second, would I say, SLEEP .25 ?? (5 Replies)
Discussion started by: Scoogie
5 Replies

3. Programming

generating timer

I'm trying generate an interrupt every 1 seconds using itimer and My clock is not running. This is what i did : printf("about to sleep for 1 second \n"); signal(SIGALRM, wakeup); //myTimer.it_interval.tv_sec=0; //myTimer.it_interval.tv_usec =0; ... (5 Replies)
Discussion started by: Confuse
5 Replies

4. UNIX for Dummies Questions & Answers

system sleep

Dear All , I installed new Linux Red Hat 9 system and it is working fine . but while i keep it for certain time ideal ( i mean ndo not wrok on system itself ) it goes to mode like sleep mode ,,, but while it is in sleep mode i can not ping it or telnet !! i discovered it while i was telnet... (8 Replies)
Discussion started by: tamemi
8 Replies

5. Programming

signal handling question

Hello all, I am starting to learn signal handling in Linux and have been trying out some simple codes to deal with SIGALRM. The code shown below sets a timer to count down. When the timer is finished a SIGALRM is produced. The handler for the signal just increments a variable called count. This... (7 Replies)
Discussion started by: fox_hound_33
7 Replies

6. Shell Programming and Scripting

Which is more efficient - sleep or infinite while?

Hi i need to make a script to check disk space every hour. ****Note that cron is not allowed. So i need to use either sleep or while 1 ...pls suggest which is more efficient in this scenario? And is there any other way to do the task? Thanks, Ashish (7 Replies)
Discussion started by: ashish_uiit
7 Replies

7. Programming

problem with sleep command

Hi all, I have a following code,(linux) #include<stdio.h> #include<unistd.h> int main() { printf("start"); sleep(3); printf("stop"); return 0; } i am getting output as first delay startstop (5 Replies)
Discussion started by: shashi
5 Replies

8. Shell Programming and Scripting

search for a file, if not found sleep and repeat it for 3 hrs

Hi, Can someone help me with this script .... I need a ksh script, which will search for a specific file in a directory, if file not found sleep for 10 mins and search again, if still not found sleep again for 10 mins and so on .... it should search for that file for 3 hours and if that file... (5 Replies)
Discussion started by: santosham
5 Replies

9. 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

10. Programming

RDTSC use in C:

I have to use rdtsc on ubuntu for performance evaluation. But i am not getting the correct value. I am placing a sleep on 10 seconds, but value i get is some 1 sec... i dont know where im going wrong? #include<sys/time.h> #include<time.h> #include<stdio.h> typedef unsigned long long ticks; ... (8 Replies)
Discussion started by: GloriousDaisy
8 Replies

11. UNIX for Dummies Questions & Answers

sleep infinity

This might be one of the dumbest questions you've got, but please bear with me: I am a UNIX beginner. I had an test today and I was asked the following question: Q. How do you put the terminal into sleep indefinitely? I didn't know the answer, but after I came home, I tried the following... (9 Replies)
Discussion started by: indyxandy
9 Replies

12. Programming

Unix Shell background processing

So I made my own unix shell, but i want to make a background process when using the & appended to the end, so far most of the commands seem to work (except cd, but thats another story) right now here is what I have got. Im thinking maybe I shouldn't be using switch and maybe switch it to... (27 Replies)
Discussion started by: Mercfh
27 Replies

13. Programming

How to sleep and wake a thread???

Hi guys, I am creating two posix threads. I have some queries, hopefully you will help me out with them 1) How can I put a thread to indefinite sleep, for indefinite time period. I am familiar with this sleep(5); for 5 second, how can I make it indefinite?? 2) How can one thread wake another... (11 Replies)
Discussion started by: gabam
11 Replies

14. Shell Programming and Scripting

Send sleep to background

Hello all, I've a small script where it checks for the existence of a particular file and sleeps for 5 seconds if it doesn't exist. I would like to send the sleep output to background so that I don't see so many sleep messages in the build output. #!/bin/sh -x until do sleep 3 done echo... (17 Replies)
Discussion started by: builderj
17 Replies