I want to write a unix shell script to run a command 3 times in every 80 seconds and write the every sequence in a different line in a text file. And also if the all results are 10 or more in a line I want to kill the process:
for example:
pstack <pid> | grep -c 'abcd'
5
pstack <pid> | grep -c 'abcd'
5
pstack <pid> | grep -c 'abcd'
5
//Nothing to do.
//after 80 seconds again it runs:
pstack <pid> | grep -c 'abcd'
10
pstack <pid> | grep -c 'abcd'
10
pstack <pid> | grep -c 'abcd'
10
kill -9 < PID> // because all three outputs are bigger than 10
also
the output file:
5 5 5
10 10 10
Note the if the output sequence is "10 10 11", "10 11 12" etc. then the process should be killed again. But if it is like "9 9 10" then no need to be killed.