I am trying to create a script which monitors the files sizes and grep the Job ID. The problem is the script returns only first ID even if there are multiple processes running. Any idea why this is not working?
#!/bin/sh
filename='bigfiles'
find /opt/Logs -type f -size +10k > $filename
count='cat bigfiles | wc -l'
while read -r line
do
pid= more "$line" | grep ID | awk -F '=' '{print $2}'>> pid.txt
done < $filename
Also I need to scan multiple directories and the script should scan for the files if the size of the log file reaches 25% of file system utilization. Any suggestions on how I can incorporate this?
This works if I use for instead of while
for line in $(cat bigfiles)
do echo "$line"
pid= grep JOBID "$line" | awk -F '=' '{print $2}' >> pid.txt
kill $(more $line | grep JOBID | awk -F '=' '{print $2}')
bhist -l $(more $line | grep JOBID | awk -F '=' '{print $2}') >> hist.txt;
done