Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Self running php script?

Tags:

php

Situation:
My php/html page retrieves the contents of another page on a different domain every 5-10 minutes or so.  I use a JavaScript setInterval() and a jquery .load() to request content from the other domain into an element on my page. Each time it retrieves content, javascript compares new content with the previous content and then I make an Ajax call to a php script that sends me an email of what the changes are.

Problem:
It's all working fine and dandy except for the fact that I need a browser constantly open, requesting the updates.

Question:
Is there a way to accomplish this with some sort of 'self executing' script on the server? Something that I would only have to start once, and it continues to run on it's own without needing a browser to be open as long as I want the script to run?

Thanks in advance! P.S. I'm not a php/javascript expert by any means, but I can get my way around.

like image 924
ksb86 Avatar asked Oct 21 '22 10:10

ksb86


2 Answers

I believe the thing you are looking for is a cron job.

like image 128
bozdoz Avatar answered Oct 24 '22 04:10

bozdoz


If your script relies on Javascript for proper execution, you will need to use a browser to accomplish your goals.

However, if you can alter your script to perform all of the functionality via PHP, perhaps using cURL to request the necessary data, you can use a cron job to execute the script at regular intervals.

like image 28
George Cummins Avatar answered Oct 24 '22 04:10

George Cummins