Create a Unix shell script with 4 parameters
source link: https://www.codesd.com/item/create-a-unix-shell-script-with-4-parameters.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Create a Unix shell script with 4 parameters
I have a file (for example system.log
). I need to scan this file to find a specific string that must appear several times during a period of 5 minutes.
I imagine that I can make a script with 4 parameters:
- the location of the file
- the string to search
- the number of times that the string appears
- the period of time
If this script finds the string in the specified period of time it writes, for example, the message 'success'
Here's the begin of the script
#!/bin/ksh
#set -x
#############
# VARIABLES #
#############
location="/moteurs/websphere/7.0/esb/managed01/logs/"
file="SystemOut.log"
pattern="WSV0605W: Thread \"SIBFAPInboundThreadPool"
string=$(grep -ic "${pattern}" ${location}/${file})
Now that I've defined my variables, I don't know how can I make a function that scans SystemOut.log
every 5 minutes.
Do you kown how can I create this shell?
Yes. Use your favorite editor, write the shell script, execute it. You are done.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK