Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking for a way to have a script running on my desktop that will check a certain webpage for changes every x seconds, and if a change is made, it gives me an alert. I understand that with high-end websites, some changes will be made almost constantly, but what I'm looking for monitoring now is a bare-bones HTML page that I'm waiting for a link to show up on. Is there a way to do this?

Edit: Would it be a command to download the html and store it, and then a recurring download-and-check command?

share|improve this question

closed as off topic by bmike Jan 20 '13 at 17:44

Questions on Ask Different are expected to relate to Apple hardware or software within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

Would a shell script (running in Terminal) be an option as well? – patrix Jan 14 '13 at 20:24
@patrix Yes, it would. – JShoe Jan 14 '13 at 21:58
In case you want to try yourself, look at curl and diff (man curl and man diff in Terminal) and read any Bash shell programming tutorial. – patrix Jan 15 '13 at 4:27
The part where this specifies to parse a multitude of HTML documents and programmatically determine if this constitutes a "change" would be better suited on An edited question on how to automate the download of one URL to a file would seem to be on topic since Automator allows that functionality. – bmike Jan 20 '13 at 17:45

Save this as ~/bin/example and run chmod +x ~/bin/example. (Edited to only check the modification date from the header.)


mkdir -p $tempdir
modified=$(curl -sI "$url" | grep ^Last-Modified)
if [[ -f "$temp" && "$modified" != "$(cat $temp)" ]]; then
    terminal-notifier -message 'Example changed'
printf %s "$modified" > $temp

To run it every 15 minutes, add */15 * * * * ~/bin/example to crontab (EDITOR=nano crontab -e).

terminal-notifier can be installed with sudo gem install terminal-notifier.

You could also run it every five seconds in a shell window:

while :; do ~/bin/example; sleep 5; done
share|improve this answer
If the server publishes an ETag or Last-Modified header, you wouldn't even need to download the whole page but only the headers reducing resource wasting on both sides. – MacLemon Jan 15 '13 at 9:06
Where is "$tmp/example" fetched from the web once to act as a baseline? – patrix Jan 15 '13 at 9:58
Sorry to be picky but $temp still needs to be initialized (e.g. by running curl -sI "$url" | grep ^Last-Modified > "$temp") – patrix Jan 15 '13 at 11:25
@patrix I forgot that -f check from the first revisions, thanks. – user495470 Jan 15 '13 at 12:58
So...I don't like using code I don't understand. I'll accept this as the answer, but sometime could someone walk me through how it works in chat? – JShoe Jan 18 '13 at 4:53

Not the answer you're looking for? Browse other questions tagged or ask your own question.