Tuesday, November 5, 2013

Monitoring a webpage through curl, sleep, and tail

There may come a time when you want to take in the results of a web page and continuously monitor it through Linux . Here's how to do it.

For linux:

Create a script with a .sh extension and add this code - for example: monitor.sh

vi script.sh
press i to insert
copy and paste the code below (edit to your liking)

#BEGIN CODE
(
while true
 do
  curl 'YourWebSitehere.com' | egrep "Multiple|Results|OrJustOne" > results3.txt
  sleep 5
 done
) &

disown
#END CODE

Then tail -f the output file.

tail -f results3.txt



No comments:

Post a Comment