We will be implementing a new template for our web site. The template actually lives on another server. I would like to schedule a script to run nightly, to check if the remote page has been updated since the last download, and if so, download the file to a directory on our server. I can use either perl or php.
In nothing but PHP, you could use something like similar_text()
(or levenshtein()
):
if(similar_text( // line breaks for clarity.
file_get_contents("/path/to/local.tpl"),
file_get_contents("http://remote.com/remote.tpl") < 90
) {// thus, if the similarity between the two files is less than 90%,
file_put_contents("/path/to/local.tpl", "http://remote.com/remote.tpl");
}// download and save the remote template.
Or, if you wanted to use rsync
- just go for system()
or exec()
and pass a script as the argument.
to make it run nightly, you just add it to the crontab:
crontab -e
add:
59 23 * * * /path/to/bash-or-php.script