1

I need to write a php script that needs to be executed every 10 mins, so I'm going to setup as a cron job like this:

*/10 * * * * /usr/local/bin/php -q /path/to/my/file.php

According to: Running php script as cron job - timeout issues?

there is no timeout for command line script, which means when running cli script set_time_limit doesn't need to be extended

I have a few questions regarding this:

  1. if I run my php using: */10 * * * * /usr/local/bin/php -q /path/to/my/file.php, will file.php become an command line script (which means it won't timeout)?

  2. do I have to add line: #!/usr/bin/php -q inside file.php?

  3. according to: http://www.php.net/manual/en/features.commandline.introduction.php I have to make sure cli is enabled (--enable-cli) so is it mean that if php is running as cgi (ie. fastcgi) or cli is not enabled (--disable-cli) then I can't setup any cron at all?

Please advise.

1
  • Worth noting that many shared hosts still kill processes that run for too long, regardless of the presence or absence of set_time_limit. Commented Jul 9, 2014 at 10:43

1 Answer 1

2

/usr/local/bin/php this runs your php file
1) it dont have timeout
2) no
3) if php runs in command line your cron will run.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.