Shell scripts - I want to monitor process id via script
-
i want to monitor specific process id and if process id stop I got the mail.
please help me to write the script. postfix is already configured.for example : PROCESS ID IS 1234
if PWDX /PID 1234 is running
then do nothing
else
echo "Process Not running sending alert mail"
mail -s "warning" <email> <message.txt -
Greetings, @Lokesh-Suthar
I whipped this up strictly based on your specifications.
Replace the used process ID with the process ID you wish to check for and replace the email addresses with yours and hopefully this does what you're looking to do.#!/bin/bash if [ $(ps aux | grep -m1 16744 | awk '{print $2}') != "16744" ]; then echo "Process 16744 is no longer running" | mail -aFrom:script@yourdomain -s "Warning: Process Not Running!" lokesh@yourdomain fi
Cheers,
Daniel -
Thank you so much.