Here are some tips to make your PHP script work perfectly:
Official tips
Add
<?php
set_time_limit(0);
ignore_user_abort(1);
?>
at beginning of your php file(s). This will let your script run until it finishes all jobs and doesn't care about users' stop button :)
Thanks Francesco for this tip :)
Personal tip
As most shared hosting disable functions set_time_limit and/or ignore_user_abort, you'd better don't output anything, or your output should be less than 4KB. Remember not to force your script to output (i.e using flush).
I tried it with shared hosting and my current server (LAMP), and my script which requires 150 seconds to complete works perfectly when set cron job at SetCronJob.
Thank you.
ReplyDelete