Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A script the can determine whitch job are still running

Status
Not open for further replies.

Larshg

Programmer
Mar 1, 2001
187
DK
Hi

I want to make a script that finds jobs that haven’t ended yet

I have a directory that contains a lot of log files (about 40.000) all the jobs have a specifik pattern they all wrights this in the last 3 lines if they have ended
***********************************************************************
* Operational Job ended successfuly on Fri Apr 26 14:23:09 MET DST 2002
***********************************************************************
or
***********************************************************************
* Operational Job ended with failure on Thu Apr 25 16:49:39 MET DST 2002
***********************************************************************

I would like to make a script that given a parameter runs though the logfiles and echo out the ls –lrt on the files that doesn’t contain “Operational Job ended”

This is the way I do it now
ls -lrt *11042002* //this gives me the logfiles with *11042002* in the name

Now I have to make a tail –3 on all the files to determine which on are still running.

The script should run something like this
[script name] *11042002*
And then give the ls –lrt information on the logfiles that does not contail “Operational Job ended” In the last 3 lines

Tanks

 
Wouldn't it be easier to use "fuser" or "lsof" to see if any process still has the file open? Tony Lawrence
SCO Unix/Linux Resources tony@pcunix.com
 
# Quick and dirty: No error checking
# if you insist on argument script_name \*11042000\*
# make sure to escape the astrics.

# Regards,

# Ed Schaefer
for file in `find . -name "$1" `
do
cnter=`tail -3 $file|grep "Operational Job ended"|wc -l`
if [ cnter -eq 0 ]
then
echo $file # bad log if no proper ending
fi
done
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top