-1

I have a rss feed (xml) that is updated frequently. I need to send notifications to APNS if new update is avaliable on rss feed (xml). So far I know I can parse xml with php and send the result to APNS with my local Apache Server on Mac (MAMP).

But I do that by simply entering php xxx.php command on terminal window.The File xxx.php first parses the xml file and then sends the results to the APNS server.

My question is

How can I periodically run this php file on a server?
Do I need a Virtual Private Server?
If so what is the code or function for running a php file continuously or every 10 mins ?

Gabriele Petrioli
  • 191,379
  • 34
  • 261
  • 317
Mord Fustang
  • 1,523
  • 4
  • 40
  • 71

3 Answers3

3

To run a file periodically you have to manage cron jobs, I wanted to describe what you have to do but I found a good profound article, It's worthy to have a look on it. http://net.tutsplus.com/tutorials/php/managing-cron-jobs-with-php-2/

Iman
  • 381
  • 1
  • 5
1

You can use cron on a linux/mac server to run periodically any command (for example: php xxx.php)

I) In a command prompt you can edit the crontab with: crontab -e

II). At the end you add a line for every script you want to run periodically. Each line must follow this pattern:

`minute` `hour` `day of the month` `month` `day of the week` `command`

For example if you want to run the script every hour you add this line:

* */1 * * * php xxx.php

III) Then exit with CTRL+X and save.

More examples on Wikipedia.

maxdec
  • 5,707
  • 2
  • 30
  • 35
0

What you need is a cron job: See this Wikipedia entry. Check to see if your host allows you to run cron jobs, and if not -- consider contacting them to see if they can set it up for you.

myhd
  • 332
  • 4
  • 22
mtsvetkov
  • 885
  • 10
  • 21