☰ Categories

Linux: How to check in a bash script if something is running and exit if it is

You can use pidof -x if you know the process name, or kill -0 if you know the PID.

Example:

if pidof -x rsync >/dev/null
then
    echo "Rsync is already running"
    exit 1fi

By: rodion and mmoya