Visit Our UNIX and Linux User Community

How to halt Prog Execution for some time?

Thread Tools Search this Thread
Top Forums Programming How to halt Prog Execution for some time?
# 1  
Old 09-07-2003
Question How to halt Prog Execution for some time?

Perhaps I am asking a silly question, but I really don't know about it. Can anyone tell me the function for "sleep" kind of functionality in C language for Unix. I don't think any function with the name of sleep() exits in Unix's C language. or perhaps I am not known with the header file required for this. Can anyone guide me about the correct function to halt the program execution for a specified time? Do tell me the header file required for the function as well.

# 2  
Old 09-07-2003
There is. Right from the man page:

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

       sleep - Sleep for the specified number of seconds

       #include <unistd.h>

       unsigned int sleep(unsigned int seconds);

       sleep()  makes the current process sleep until seconds seconds have elapsed or a
       signal arrives which is not ignored.

       Zero if the requested time has elapsed, or the number of seconds left to  sleep.

# 3  
Old 10-10-2003
There's also usleep to do the same with microsecond granularity.
# 4  
Old 10-15-2003
If you do 'man sleep' you will get the first entry it finds which is the shell sleep command in manual section 1(?).

To get the C definiton of the sleep function you need to qualify the manual section to search into: 'man 3 sleep'

Previous Thread | Next Thread
Test Your Knowledge in Computers #608
Difficulty: Easy
Python does not need compilation to binary to run.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need to reduce the execution time

We are trying to execute below script for finding out the occurrence of a particular word in a log file Need suggestions to optimize the script. Test.log size - Approx to 500 to 600 MB $wc -l Test.log 16609852 Test.log po_numbers - 11 to 12k po's to search $more po_numbers xxx1335... (10 Replies)
Discussion started by: KumarPiyush7225
10 Replies

2. Shell Programming and Scripting

To take script execution time

Hello Guys, I would like to know is there a way to take the script execution time For e.g i am having a i need to write inside he like Start time : 10-Mar-2016 02:30:35 all code over here ... End time : 10-Mar-2016 03:30:32 Script start time - 02:30:35 ... (7 Replies)
Discussion started by: Master_Mind
7 Replies

3. UNIX for Dummies Questions & Answers

time taken for execution

how much time a particular command or shell script executed there is any command to know this thanks (5 Replies)
Discussion started by: tsurendra
5 Replies

4. Shell Programming and Scripting

time of execution of script

i want to test whether a script has been executed in last 15 days or not....please help how can i do there any copmmand there to know timings of last execution of any script (8 Replies)
Discussion started by: arghya_owen
8 Replies

5. Shell Programming and Scripting

command execution time

Hi all, I want to display a progressbar depending upon the completion status of a command. I am coding from scratch as I dont want to use in place code. so Is there anyway of getting the progress of a command in percentage or in any other units while its running , is it possible using the top... (5 Replies)
Discussion started by: hashin_p
5 Replies

6. Shell Programming and Scripting

To reduce execution time

Hi All, The below script I run daily and it consumes 2 hours approx. In this I am calling another script and executing the same twice. Is the loop below the cause for the slow process?Is it possible to finetune the program so that it runs in a much faster way? The first script: #!/bin/ksh... (4 Replies)
Discussion started by: Sreejith_VK
4 Replies

7. Shell Programming and Scripting

Estimated execution time

Hi All, One of my script runs (approximately) for 20 to 40 hours Is there any way in unix to find the estimated time required for a shell script(Cron job).ie to find the time required for execution even before the script is executed. Any discussion(pointers) regarding the same is most welcome. (4 Replies)
Discussion started by: Sreejith_VK
4 Replies

8. UNIX for Advanced & Expert Users

specifying an execution time

Hi all, do ny o u'll know how to set a particular execution time for a program??? for eg.: --> during the execution of a file, i call a certain other function. --> while calling this function, my comp hangs. now is there ny way in which i can go to the nxt line of code by aborting the call... (7 Replies)
Discussion started by: VGR
7 Replies

9. UNIX for Dummies Questions & Answers

last execution time

is there a command in Solaris 8 that will show a particular scripts last execution time? (1 Reply)
Discussion started by: cubs0729
1 Replies

10. Programming

execution time

hi , i ve coded a C program in that im using malloc dynamically , it is being called many times in the program The program is to simulate jobs in manufacturing system. the execution time is increasing drastically as the number of jobs are increased. could any body tel what may be the problem... (2 Replies)
Discussion started by: ramki_rk
2 Replies

Featured Tech Videos