1826159 Members
4593 Online
109691 Solutions
New Discussion

want to write script

 
Amit Phadnis
Advisor

want to write script

Hi,

I want to write a script in unix. I want your support in forming the script. I am mentioning my aim for the script.

we have a unix servers in which we have certain jobs which continiously monitor the server errors. we have set the prirorities for that such as high, medium, low for which the log files are getting created which we can differentiate.
now my requirement of script is such that it should scan the these high priority logs only and should mail those to the concerned guys on there mail-id's.it will be such like alerts for these guys.

waiting for your solution,

Thanks and Regards,
Amit Phadnis.
Now my requirement for the script is such tha
1 REPLY 1
Matti_Kurkela
Honored Contributor

Re: want to write script

You did not describe exactly how to identify the priority in the log messages.

If the priority information is embedded in the log messages, for example, if the high priority messages always have "" in them,
the solution is to use "grep" to scan for high priority messages and pipe the output to "mail" for sending.

This is usually done with just one line of script, like this:

grep "" /one/or/more/log/files.txt | mail -s "mail subject" one.or.more@mail.addresses

If there is no single identifier for high-priority messages, but you can list the kinds of messages that are high-priority, read "man grep" and pay attention to the -F option.

By the way, this is is a *very, very simple* script. If you cannot do this much on your own and you must work as Unix sysadmin, go to some "Unix basic system administration" course ASAP.

MK
MK