PHP cronjob variables -


i have complete old project uses php cronjob. within cronjob have check variable this

defined('_cronjob') or die; 

this constant can take different values indicate job do:

switch(_cronjob){  //...more code } 

how can set variable when calling cronjob. in advance.

since you'll use cron launch script, can use cli parameters , pass value script. handle parameters can use simple way, like:

define('_cronjob', $_server['argv'][1]); //equal 1-st parameter 

in case launch like:

/path/to/bin/php /path/to/script.php foo 

and _cronjob equal foo

alternative , more advanced way use getopt() , grab named parameter. more readable , you'll able not rely on parameter order (i.e. first exactly). recommend use way.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -