user1559230
user1559230

Reputation: 2811

How to keep a php script running for 4 to 5 days using cron job?

I have a php script in codeignitor framework. It works on complex calculation algorithm which needs to keep the script running for at least 4 to 5 days. But it stops after running for few hours. How can I make it keep running until the script finishes?

cron command:

13 21 * * * /usr/bin/php /var/www/project/index.php 'test/mytest'

Upvotes: 0

Views: 467

Answers (4)

A human being
A human being

Reputation: 1220

I think you should use GNU screen for doing this thing. Start a screen, start your PHP script, detach the screen.It'll run until you kill the screen.

Upvotes: 1

ITroubs
ITroubs

Reputation: 11215

You could set your max_execution_time to 432000

But since there is always something else that could stop your script, I would considder making it interruption robust.

Upvotes: 1

user1467267
user1467267

Reputation:

set_time_limit(0); will remove the time-out safety protocol PHP has built-in. Be aware there are more factors, like system breaks and apache/webpanel protocols, that might still abort the script if it runs too long. Some webhosters for example still abort your script, even if you remove the time-out limit.

Good luck testing!

Upvotes: 1

ulentini
ulentini

Reputation: 2412

Perhaps it depends on max_execution_time in php.ini

Upvotes: 2

Related Questions