You are here:  » How to use cronjobs to get it to automate?


How to use cronjobs to get it to automate?

Submitted by Klaas Koopman on Wed, 2009-02-18 09:54 in

Hey all,

This forum has been a great help( with this forum i mean david hehe ), but now I have another question. I made use of an xml feed that was on a certain url and made it to populate my database and then I imported from the database on to my website ( if that makes sense ).

But how do I make it, so when something changes in the xml feed, it also changes in my database and/or my site? I heard something about cron jobs, but I have no knowledge on that field.

Submitted by support on Wed, 2009-02-18 10:45

Hello Klaas,

A cron job is what you need to do this. You might find that your hosting control panel has a "cron" section to it; that would be the first place to look. If it does, you can normally use it to schedule a PHP script to run at the time you want (for example 2AM each day).

All you need to do is schedule the PHP script that loads the database by reading the feed, and then parsing it. What you type in to the "command" box when creating a cron job can vary by host to host, so it might be worth contacting support if you're not sure.

Some are setup so you can just enter a URL, simply:

http://www.example.com/scripts/loadDatabase.php

...but you might need to enter a normal command line, for example:

php /path/to/scripts/loadDatabase.php

...so best to check with your host if you're not sure. The question to ask is simply "How to I use the cron service on my account to make a PHP script run...?"

Hope this helps!
Cheers,
David.