0

I would like to create Linux shell script which reads a log file.

for eg. I have log file with lines:

Job: One(106) started.
Job: Two(107) started.
Job: Name(111) started.
Job: EXE(112) started.
Job: SMTG(117) started.
...........
.....
...

I want to make script which checks all jobs and sends email if job status is not started. Job status could be error, locked, stopped and everything else. I don't know how to write script to check exactly if status is not started.

2 Answers 2

1
awk '$0!~/started/{print}' logfile | mail -s "Jobs not started" [email protected]
0
grep -v 'Job:.*started.' yourfile.log | while read line; do
    # your not started line is here
    echo $line
done 

Little explanation: grep will read your file and filter out lines matching a pattern, so we don't match started jobs. Then you are reading not started lines, you can replace echo $line and send an email there.

2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .