pidwait command
waiting for another process to stop using process name or PID file
Typical usage: shell scripting, job control, process monitoringIntroduction into pidwait
The pidwait command helps with waiting for a task to complete. This is useful with shell scripting or tasks that may take a while to complete, but you don’t want to monitor the screen manually. While using pipes (command1 && command 2) is possible to schedule the next task, pidwait will let you monitor the process state outside a piped set of commands. A good example of this is daemon processes that are running and normally are not started manually but with a script.
To use the command, the Linux kernel should be 5.3 or higher, as this command uses the syscall pidfd_open(2).
Installation
When pidwait is not installed by default, it can be added to the system using the relevant software package.
Package information for pidwait
| Operating system | Package name | Installation |
|---|---|---|
| AlmaLinux | procps-ng | |
| Arch Linux | procps-ng | |
| Debian | procps | |
| Fedora | procps-ng | |
| Red Hat Enterprise Linux | procps-ng | |
| Rocky Linux | procps-ng | |
| openSUSE | procps | |
| Ubuntu | procps | |
Your Linux distribution using a different package? Share your feedback.
Usage
Available options
| Long option | Short option | Description |
|---|---|---|
| --pidfile | -p | Retrieve the process ID (PID) from a specified file |
Missing an option in this overview? Share your feedback.
Examples using pidwait
Wait for nginx to stop by using its PID file
pidwait --pidfile /run/nginx.pidWait for nginx to stop
pidwait nginxFrequently Asked Questions
What is the pidwait command and its purpose?
The pidwait command is a command-line tool to wait for a process to stop
Which package provides the pidwait command?
The command pidwait is provided by the procps or procps-ng package.
Related and similar commands
Linux has a lot of tools and commands available and sometimes you just need that little other tool. Here is a list of commands that are similar or related to pidwait:
| Command | Category | Summary |
|---|---|---|
| basename | files | Strips directory and file name suffix from a given path |
| chrt | processes | Sets Linux scheduler policy and priority for a process or command |
| kill | processes | Sending signals to processes |
| nice | processes | Runs commands with specified priority |
| numactl | processes | Controls NUMA policy for processes and shared memory |
| peekfd | processes | Tracks a process and show file descriptor activity |
| pidof | processes | Returns process IDs for a process name |
| pidstat | monitoring | Monitoring CPU, memory, and disk activity |
| pmap | processes | Shows memory mapping of process |
| prtstat | processes | Shows process details for selected process like state, CPU and memory usage |
| pscap | capabilities | Display available capabilities for running processes |
| pslog | logging | Shows which log files a process has opened |
| pstree | processes | Show active processes and children like a tree |
| pwdx | processes | Shows current working directory of a process |
| renice | processes | Changes the priority of running processes |
| slabtop | memory | Shows slab usage of kernel |
| smem | memory | Show memory usage including swap |
| strace | process inspection | Inspects running process |
| units | data conversion | Converts a unit into another one, like from Celcius to Fahrenheit |
| watch | processes | Monitors changes in output of specified command |
Also 💙 the command-line or terminal? Here is a set of cheat sheets for Linux to get more done from within the shell: