Check if process is running on Linux

02.Mar.2013

If you’d like to check if process is running on Linux OS, you can do it by using code from following snippet:

command = "sidekiq"
running = `ps ax | grep -v grep | grep $command | wc -l`
 
if [running -gt 0]; then
    echo "Sidekiq is running!"
else
    echo "Sidekiq is not running..."
fi