Php – Adding/Removing cron job using PHP

cronPHP

Here's my situation: We have an outside provider that will be pushing XML files to our server every 30 seconds at a specified time in the week.  That time will vary each week. So, I would like to give my users an interface on the management side of our site where they could "push a button" and trigger the capturing of data. (and in the same way be able to turn the job off)

I have planned to do this using PHP. I assume that I'll need to run some system commands from my script to schedule and delete cron jobs. 

My question is: Is this the best way to do this? Is there any danger in scheduling and deleting cron jobs from php?  What things do I need to keep in mind as I'm creating this?

Also, any pointers/hints at how to accomplish this are more than welcome. Thanks in advance. 

Best Answer

I would recommend just keeping the cron job that looks for the uploaded XML files running all the time, every minute. Checking to see if there are any files in a directory is not an expensive enough operation that you need to make an involved administrative interface to turn it off when not needed.