pidwait command

waiting for another process to stop using process name or PID file

Typical usage: shell scripting, job control, process monitoring

Introduction 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 systemPackage nameInstallation
AlmaLinuxprocps-ng
dnf install procps-ng
Arch Linuxprocps-ng
pacman -S procps-ng
Debianprocps
apt install procps
Fedoraprocps-ng
dnf install procps-ng
Red Hat Enterprise Linuxprocps-ng
dnf install procps-ng
Rocky Linuxprocps-ng
dnf install procps-ng
openSUSEprocps
zypper install procps
Ubuntuprocps
apt install procps

Your Linux distribution using a different package? Share your feedback.

Usage

Available options

Long optionShort optionDescription
--pidfile-pRetrieve 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.pid

Wait for nginx to stop

pidwait nginx

Frequently 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:

Related and similar commands to pidwait
CommandCategorySummary
basenamefilesStrips directory and file name suffix from a given path
chrtprocessesSets Linux scheduler policy and priority for a process or command
killprocessesSending signals to processes
niceprocessesRuns commands with specified priority
numactlprocessesControls NUMA policy for processes and shared memory
peekfdprocessesTracks a process and show file descriptor activity
pidofprocessesReturns process IDs for a process name
pidstatmonitoringMonitoring CPU, memory, and disk activity
pmapprocessesShows memory mapping of process
prtstatprocessesShows process details for selected process like state, CPU and memory usage
pscapcapabilitiesDisplay available capabilities for running processes
pslogloggingShows which log files a process has opened
pstreeprocessesShow active processes and children like a tree
pwdxprocessesShows current working directory of a process
reniceprocessesChanges the priority of running processes
slabtopmemoryShows slab usage of kernel
smemmemoryShow memory usage including swap
straceprocess inspectionInspects running process
unitsdata conversionConverts a unit into another one, like from Celcius to Fahrenheit
watchprocessesMonitors changes in output of specified command