Automate Job monitoring


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Automate Job monitoring
# 1  
Old 11-13-2012
Automate Job monitoring

Hi,
I have a project which i need to automate some manual work. We have a 100 jobs in Linux and Unix environment. We do job monitoring daily. that is taking more that 2 to 3 hrs for us because we use autorep -j <jobname> command for each and every job. That takes more time for us to do.
We have to automate it.
We have a list of jobs in xcel/csv files. We have added this command in all jobs like below.
autorep -j job_one
autorep -j job_two
.
.
.
autorep -j job_one_hundred
If i am running this command i am getting below output.
bash-2.05$ autorep -j gxxxxxxx
Job Name Last Start Last End ST Run Pri/Xit
____________________________ ____________________ ____________________ __ _______ ___
gxxxxxxx(box job) 11/08/2012 16:00:08 11/08/2012 16:03:43 SU 18472621/1
gyyyyyy(command job) 11/08/2012 16:00:49 11/08/2012 16:01:01 SU 18472621/1
Now my requirement, i have to create shell script. It should read all autorep command from xcel/csv sheet, Run autorep command and output should store in xcel/csv, send that mail to specific group. Output Excel should have Job Name(command and box jobs), Last Start, Last End and ST of all jobs and should display.
How could i achive this?
# 2  
Old 11-13-2012
You can write a while loop to read all autorep command, execute, write status to a file:-
Code:
print "Job Name, Last Start, Last End, ST" > job_monitor.csv
while read autorep_cmd
do
   $autorep_cmd | awk 'NR>2 { print $1, $2 " " $3, $4 " " $5, $6 } ' OFS="," >> job_monitor.csv
done < job_cmd.csv

cat job_monitor.csv | mailx -s "Job Monitor" someone@domain.com

This User Gave Thanks to Yoda For This Post:
# 3  
Old 11-13-2012
I am new to unix.
Could you please give me exact code for this?
# 4  
Old 11-13-2012
The code which I provided will work, just replace file name: job_cmd.csv with the CSV file name that you have with the list of autorep commands.
# 5  
Old 11-13-2012
i am getting blank file as output.
Code:
#!/bin/sh
 
print "Job Name, Last Start, Last End, ST" > job_monitor.csv
while read autorep_cmd
do
   $autorep_cmd | awk 'NR>2 { print $1, $2 " " $3, $4 " " $5, $6 } ' OFS="," >> job_monitor.csv
done < job_cmd.csv


Last edited by Franklin52; 11-15-2012 at 04:03 AM.. Reason: Please use code tags for data and code samples
# 6  
Old 11-13-2012
What do you have in job_cmd.csv file? Can you please post the output of below two commands:-
Code:
head job_cmd.csv

Code:
head job_monitor.csv

Please use code tags when posting code segments.
# 7  
Old 11-13-2012
Code:
 
$ head job_cmd.csv
autorep -j job_name_xxxxxxx
$ head job_monitor.csv
Job Name, Last Start, Last End, ST $


Last edited by cg_saran; 11-13-2012 at 10:59 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. What is on Your Mind?

Script to alert with email after a job got successful in monitoring tool

Hi guyz, Please send me a script which is to be sending an automatic email to particular mail id's when a job get complete with status successful. Please send me your script to my mail id : rehan.csjmu@gmail.com Thanks in Advance. ---------- Post updated at 11:33 AM ----------... (1 Reply)
Discussion started by: Rehan Ahmad
1 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. Shell Programming and Scripting

Script to Start a Job after finding the Old job completed

Hi Experts, I need a script advice to schedule 12 jobs ( SAS Codes execute back ground ). Algorithem: 1. Script checks first job. 2. Finds first job is done; invoke second job. 3. finds second job is done; invoke third job. .. Request you to please assist. (3 Replies)
Discussion started by: Jerald Nathan
3 Replies

4. Shell Programming and Scripting

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... (6 Replies)
Discussion started by: asalman.qazi
6 Replies

5. Shell Programming and Scripting

Error in script to automate the daily monitoring process of UNIX server and it's proc

hi friends, I am trying to automate the daily monitoring process of UNIX server and it's processes. the script are below i executed the above script using ksh -x monitortest1.sh in root login . It shows error at some lines . 1. i logged in using root ,but it... (8 Replies)
Discussion started by: rdhaprakasam
8 Replies

6. Shell Programming and Scripting

Automate Log Monitoring Process

I am a new member of this forum and am also new to unix shell scripting. I joined the forum to seek for help to achieve my task as this forum helps people. here's what i do manually on daily basis 1)Loginto different unix box 2)Ftp the log files (morethan 50 each dir) to windows 3)use text pad... (3 Replies)
Discussion started by: sharugan
3 Replies

7. Programming

Job monitoring script

Hi, We are running a list of jobs (nearly 100 jobs). We have to monitor these jobs through their log files and based on job's exit status. If any one friend have this kind of scripts that will help me to create my own script. Please give me some codes. Your's loving friend. Love... (1 Reply)
Discussion started by: Love
1 Replies

8. Solaris

killing a unix job after the job process gets completed

Hi, Thanks in advance. i need to kill a unix background running job after that job process completes. i can kill a job by giving the following unix command kill -9 processid how to kill the job after the current process run gets completed ? Appreciate your valuable help. Thanks... (7 Replies)
Discussion started by: dtazv
7 Replies

9. Shell Programming and Scripting

killing unix job after the job process completes

Hi, Thanks in advance. i need to kill a unix background running job after that job process completes. i can kill a job by giving the following unix command kill -9 processid how to kill the job after the current process run gets completed ? Appreciate your valuable help. ... (1 Reply)
Discussion started by: dtazv
1 Replies

10. UNIX for Dummies Questions & Answers

automate an ftp job

Hi, I am trying to write and automate a ftp job that connects to a IBM mainframe and pulls the same files everyday. To do this I assumen I create a .netrc file in my solaris home directory, then I write a shell script. How do I envoke ftp from a ksh script and pass it the info in .netrc? I... (11 Replies)
Discussion started by: flowrats
11 Replies
Login or Register to Ask a Question