3.5 Execute process commands: like ps, wait, sleep, exit, kill

22516 Operating System MSBTE CO IT 3.5 Execute process commands: like ps, wait, sleep, exit, kill

Here are the explanations and examples of the commands you've mentioned:

  1. ps: The ps command (short for process status) is used to provide information about the currently running processes, including their process identification numbers (PIDs).

Example usage: ps -ef will display all the currently running processes in the system.

 

  1. wait: The wait command is used in shell scripting primarily. When run, it causes the script or the shell to wait for all background jobs or specified JobID/PIDs to terminate before resuming execution.

Example usage: wait %1 will cause the shell to wait for the completion of the job with JobID 1.

 

  1. sleep: The sleep command is used to create a dummy job during scripting. A dummy job helps in delaying the execution.

Example usage: sleep 10 will halt the execution of the next command for 10 seconds.

 

  1. exit: The exit command is used to end the shell where it is currently running. It makes the shell exit, and if the shell is a login shell, then it terminates the login session.

Example usage: exit will terminate the shell.

 

  1. kill: The kill command is used to send a signal to a process. By default, it sends a TERM (terminate) signal to the specified process.

Example usage: kill 12345 will send the TERM signal to the process with PID 12345. If the process doesn't terminate, a stronger KILL signal can be sent with kill -9 12345.

 

Remember, these commands are typically used in Unix-like operating systems, including Linux distributions. The exact details or options might vary between different systems. Be sure to consult the man pages (man <command>) in your system for the exact usage details.


Post a Comment

Previous Post Next Post