What is the difference between the commands sleep, wait and killall?

sleep:

This command is used in UNIX operating system to suspend execution of the system for the specified time limit mentioned in it as parameter.


The general format of sleep command is



sleep no_of_seconds



The sleep suspends the execution of the shell in UNIX operating system for the no_of seconds specified.


For instance



sleep 5



The above suspend the execution of the shell in UNIX operating system for 5 seconds specified.


wait:

wait causes waiting of the process specified in parameter or the job specified in parameter to wait. If nothing is specified all jobs in pipeline are put to waiting state that is all current child process which are currently active are put to wait status. Wait also return the return status. The return status is generally the exit status of last job in the pipeline process which was put to waiting state. In case of scenario in which no job or process is specified the return status would be zero.


The general syntax of wait command in UNIX operating system is



wait n



where n is optional which denote the process or job


killall:

The command killall is used to kill processes which are active. The main aspect in this is killall command can be issued only by the super user.

Questions by GeekAdmin   answers by GeekAdmin

Showing Answers 1 - 3 of 3 Answers

sudhir deshmukh

  • Mar 8th, 2007
 

sleep is a Unix command line program that suspends program execution for a specified period of time.


Wait

The wait function suspends execution of the current process until a child has exited, or until a signal is delivered whose action is to terminate the current process or to call a signal handling function. If a child has already exited by the time of the call (a so-called "zombie" process), the function returns immediately. Any system resources used by the child are freed.
The waitpid function suspends execution of the current process until a child as specified by the pid argument has exited, or until a signal is delivered whose action is to terminate the current process or to call a signal handling function. If a child as requested by pid has already exited by the time of the call (a so-called "zombie" process), the function returns immediately. Any system resources used by the child are freed.

Killall

killall sends a signal to all processes running any of the specified commands. If no signal name is specified, SIGTERM is sent.

Signals can be specified either by name (e.g. -HUP) or by number (e.g. -1).

If the command name contains a slash (/), processes executing that particular file will be selected for killing, independent of their name.

killall returns a zero return code if at least one process has been killed for each ilisted command. killall returns zero otherwise.

A killall process never kills itself (but may kill other killall processes)

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions