I have to monitor several processes in my application .
i get the listing of these processes using the command ps -ax
i want to write a shell script that will monitor the processes and if a
process goes missing then it will send an email to my gmail account.
I want to run this script as a cron job that will start every 15min.
kindly provide me with the shell script and the directory in the server
where this shell script needs to be placed and the cron entry for running
this script every 15min. I need all this information as i am new to unix
and i have to implement this stuff on my server as soon as poosible.
Please any one help me!!!!!(my OS is Solaris 5.6)
and
aren't the same. To start with, I suggest
man crontab
I know how cron works. But i haven't made any changes to it as of now.The basic problem is , how my cron job will monitor the process and send an email when the process goes missisng
First, as to your private message, google "linux command line email" and look at the first link.
To this question, what have you tried? You mentioned ps output, you'll have to do something with that output to get what you want. From what I've seen, most folks on here are happy to help with specific problems but have other jobs to do.
An answer to the question "this script is having problems and I need some help" will have a much different answer than "these are the requirements I have, please write the script for me".
grep "CMIS_STACK_LAN" processlist.txt
if [ $? -ne 0 ]
then
CMIS_STACK_LAN & (this is used to restart the CMIS process which is stoped)
date > error.log
echo "the process CMIS has stopped" >> error.log
fi
---------- Post updated at 11:02 AM ---------- Previous update was at 10:50 AM ----------
peterro,
the command CMIS_STACK_LAN & is used to restrt my application process
there are to users in my server
1)root
2)net1
now to run the above command, i will have to be net1 user
so when i run this command manually i have to do the following
su net1
CMIS_STACK_LAN &
now when i do the same thing in a script , the command does not run
the CMIS_STACK_LAN is a C code that runs continuously on the server.
this is so far my progress.
Can any one of the gurus out there help me out with this
Hi Neo,
I have figured that out
before doing
grep 'CMIS_STACK" process.txt,
i will have to do ps -ax > process.txt
thanks for pointing out my mistake.
now my problem is , i have to run the CMIS process if it is missing
i have to run this process from user netmon.
on command prompt ,i have to do the following.
su - netmon
CMIS_STACK &
and the process starts successfully.
but when i include the same things in a shell script , the scripts exits,
without restarting the process.
can you please help me out with the problem
You could run the monitor job as either the netmon user or see if the -c switch is available on your version of su. It allows you to run a single command as another user.