Cron job for monitoring processes


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Cron job for monitoring processes
# 1  
Old 08-06-2009
Cron job for monitoring processes

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)
# 2  
Old 08-06-2009
Quote:
...i want to write a shell script...
and

Quote:
...kindly provide me with the shell script...
aren't the same. To start with, I suggest

Code:
man crontab

# 3  
Old 08-07-2009
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
# 4  
Old 08-07-2009
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".
# 5  
Old 08-08-2009
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
# 6  
Old 08-09-2009
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
# 7  
Old 08-09-2009
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Cron job - Need to run Cron every quarter at particular time

Hi, 1) If some job supposed to run on 1st of every month at 7 AM In cron job when we have a blackout on the 1st ( i.e when 1st falls on a sunday ) how can we make the job run the next business day? 2) How can we run a job on 25th of every quarter 7 AM(jan,apr,jul,oct) And if 25th... (5 Replies)
Discussion started by: System Admin 77
5 Replies

2. Shell Programming and Scripting

Commented cron job -- cron monitoring

Hi I have a requirement to write a shell script,that will check the all commented job in cron job.Please help !! (2 Replies)
Discussion started by: netdbaind
2 Replies

3. Solaris

Cron job running even after cron is removed

Hi , I have removed a cron for particular user , but cron job seems to be running even after the cron entry is removed. The purpose of the cron was to sendmail to user ( it uses mailx utility ) I have restarted cron and sendmail service still user is getting mail alerts from the cron job. And... (4 Replies)
Discussion started by: chidori
4 Replies

4. Programming

Need C program for monitoring a processes that are running in different nodes

Hey, I am doing a high availability project. I need coding(socket programming using C) to monitor processes that are running in different nodes with in a network cluster.At last if u could give me a program in C to monitor the process(whether it is running or failed),it would be very... (2 Replies)
Discussion started by: vigneshinbox
2 Replies

5. UNIX for Dummies Questions & Answers

monitoring 'waiting' processes

Is it possible to monitor processes whether they are waiting or active? Basically I would like to know since which TIME the process has been running and the state. :confused: (3 Replies)
Discussion started by: jon80
3 Replies

6. Solaris

cron job starts new cron proccess

I run cron in solaris 10 zone. One cron job which syncing files to nfs mounted on container, creates after finishing another cron proccess(/usr/sbin/cron), and after 100 existing cron proccesses next cron job will not start. It's too weird for me, I'm not able to solve this problem. Theoretically... (3 Replies)
Discussion started by: ron76
3 Replies

7. UNIX for Advanced & Expert Users

Monitoring Processes - Killing hung processes

Is there a way to monitor certain processes and if they hang too long to kill them, but certain scripts which are expected to take a long time to let them go? Thank you Richard (4 Replies)
Discussion started by: ukndoit
4 Replies

8. Shell Programming and Scripting

monitoring running processes

I have a script that runs continuously and will deliver a file to multiple servers via scp. On occasions one of the scp's will hang and as a result not complete in sending the remaining files and not loop around again. If I run the scp commands with a & they'll complete, but I want to make sure... (2 Replies)
Discussion started by: nhatch
2 Replies

9. Shell Programming and Scripting

Monitoring processes of another host

Does anyone have a script, which monitors the processes of another host? (5 Replies)
Discussion started by: Andimotz80
5 Replies
Login or Register to Ask a Question