简体   繁体   中英

Launch PHP script from cron?

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

/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 .

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM