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
Post a Comment