Scheduled task (cronjob) with PHP

198 views Asked by At

I'm creating a website that requires a file to be generated and stored on the server periodically (an XML feed for iTunes). The page is generated using ExpressionEngine. I discovered that the website's current server has a very restricted cPanel and doesn't have access to cron.

So I'm considering two options; find an alternative way to access the cronjobs (if they are available), or find an alternative way to created regularly scheduled tasks.

Regarding the first option, how would I go about determining if a server has cron available? I'm not sure how useful this would be anyway since I don't think the server allows shell access (it's a very basic setup for people who aren't tech savvy).

Regarding the second option, a friend mentioned to me that the functionality of cronjobs can just be done in PHP. How would I go about this?

Or, am I perhaps thinking too much with this? The page in ExpressionEngine that outputs the XML file is domain.com/itunes/itunes_feed. This just has some EE tags that outputs the relevant XML and the resultant page is in .xml format. Is it enough to just submit the above url to iTunes, or does it have to be a url to the actual pre-existing file on the server?

1

There are 1 answers

2
dev On

Option 1

  • Simply contact your hosts and ask them do they support cron jobs, and if so, how to set up.

Option 2

  • I only just set up my own set of cron jobs yesterday..
  • Create a php file that runs the code you want,
  • Set up and account on https://www.easycron.com/
  • Upload your php file to easycron
  • Set the times in which you would like your php code to run

Simple as that! Does that make sense?