#!/bin/bash
PROCESS_NAME="queue:consumers:start specificName"
START_COMMAND="/usr/bin/php8.2 /var/www/project/html/bin/magento queue:consumers:start specificName --single-thread --max-messages=20000"
pgrep -f "$PROCESS_NAME" > /dev/null
PGREP_STATUS=$?
# 0 - found, 1 - not found
if [ $PGREP_STATUS -ne 0 ]; then
echo "$(date '+%Y-%m-%d %H:%M:%S') - The process $PROCESS_NAME wasn't found, restarting..."
$START_COMMAND &
pgrep -af "PROCESS_NAME"
fi