0

I have a wordpress web application and inside the root directory I have a file: data.php which contains code to fetch data from a JSON feed and store it in the wordpress database.

However since I am deploying this to a server, I need to tell the script to run after I deploy the my local wordpress site to the server and then after that it should only run/fetch data after every 2 hours.

How would I set this?

Mutuma
  • 1,893
  • 2
  • 20
  • 31

1 Answers1

0

create a cron job in your server to run your code
Read this question: Run a PHP file in a cron job using CPanel

If your host moderator panel is cPanel, look this two links:
cPanel cron job docs
Cron job to run php

Community
  • 1
  • 1
Farnabaz
  • 3,870
  • 1
  • 18
  • 39
  • The web app is deployed to azure and the package I have does not include include getting access to a virtual box .... is there no php function I can use to do this? – Mutuma Mar 29 '14 at 12:10
  • @Mutuma read this answer may be this help http://stackoverflow.com/questions/4421020/use-php-to-create-edit-and-delete-crontab-jobs – Farnabaz Mar 29 '14 at 12:22
  • I am hosted on Azure so I guess cron jobs won't work especially since I'm on windows – Mutuma Mar 29 '14 at 12:32
  • oh, you right, Azure have pure ability to ask scheduling, what I want to say may be very bad solution but it maybe solve your problem. every time a user sent request to your site (load a page) check your last `run/fetch` time, and rerun your code if necessary – Farnabaz Mar 29 '14 at 12:42