Php – long time cron job via wget/curl

cronphp

I am working on cron jobs for my php app and planning to use cron via wget/curl.
Some of my php cron jobs can take 2-3 hours. How to let php work 2-3 hours from cron tab ? Is it good practice to run such long time jobs via cron wget/curl ? Anyone got experience on this ? I also have email queue and i needs to be run every 10 seconds, but cron tab is minute level. Any suggest on this case ?

Thanks for reading.

Best Solution

When you use wget/curl, you are requesting for a page from a webserver. Every webserver will have a time out period, so this might time out.

Also some of the hosting providers may stop the process running beyond certain minutes ( basically done to control the rogue threads).

So it is not advisable to schedule using wget/curl if the job takes more than few minutes.

Try scheduling it using actual scheduler. You can run php from command line

php [options] [-f] [--] [args...]

php command should be on the path.

Related Question