1

I know you need to put /usr/local/bin/php -f in cron before path to php file e.g.

/10 * * * * /usr/local/bin/php -f /home/public_html/scrip.php

but should i use -q or -f?

When i run /usr/local/bin/php --help it does not show any -q option yet many tutorials online say -q.

3 Answers 3

2

The -q option just suppresses output from the PHP executable. This is useful when running a PHP script as a cron job. So really, you should use both.

See "man php" for more information.

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

Comments

2

The -q stands for quiet mode which will suppress all the HTTP headers from being sent along with it. Anything outputted by the script will be just that output.

PHP has full documentation on command line options on their website.

Comments

2

According to the docs, -q does the following

Quiet-mode. Suppress HTTP header output (CGI only).

You don't really need any options to run a PHP script from cron.

2 Comments

@JohnA: Yes, the CLI version of PHP already suppresses HTTP headers.
@JohnA: Correct. There is no need to suppress output when used as Apache (or other web server) module.

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.