Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the -q PHP command-line option do?

Tags:

php

I have a cron job on my host:

/ramdisk/bin/php5 -q /home2/sharingi/public_html/scrape/copyV2.php

That is just plain not running. The 'support' is telling me that -q is quiet mode and that is why I am not receiving any output emails of any kind...

However all my other cron jobs have been and are running with -q and have been sending me output emails... for months.

I was searching around but can't find what the -q flag does, so can you tell me?

like image 371
ian Avatar asked Jan 14 '10 10:01

ian


People also ask

What is PHP command line?

PHP supports CLI SAPI(Command Line Interface Server API) for executing the script from the command line. This SAPI will differ from other interfaces based on the IO practices, configuration defaults, buffering and more. For example, IO practices – it will not support the PHP request method (GET, POST).

Can we use PHP in command line?

After installation of PHP, we are ready to run PHP code through command line. You just follow the steps to run PHP program using command line. Open terminal or command line window. Goto the specified folder or directory where php files are present.

How do I run a command line argument in PHP?

There are two predefined variables in PHP, called $argc and $argv , that you can use to work with command-line arguments. The variable $argc simply tells you the number of arguments that were passed to the script. Remember that the name of the script you are running is always counted as an argument.


1 Answers

The -q flag suppresses HTTP header output. As long as your script itself does not send anything to stdout, -q will prevent cron from sending you an email every time the script runs. For example, print and echo send to stdout. Avoid using these functions if you want to prevent cron from sending you email.

like image 171
St.Woland Avatar answered Oct 14 '22 18:10

St.Woland