You can use command line arguments, but you need to use the $argv array. And the $argv array is only available if the register_argc_argv setting is enabled in PHP.
This is disabled by default, but you can create a php.ini file to enable register_argc_argv.
To enable this setting:
register_argc_argv = On
You can then specify this particular php.ini file in the command for the scheduled task. For example, if you use:
/usr/bin/php5 –c /home/sites/your-domain.com/php.ini /home/sites/your-domain.com/cron.php argument1 argument2
The cron.php file will be able to use argument1 and argument2 when running.
Article ID: 432
Created On: Mon, Mar 16, 2015 at 3:50 PM
Last Updated On: Thu, Apr 23, 2015 at 12:20 PM
Online URL: https://www.heartinternet.uk/support/article/can-i-use-command-line-arguments-with-a-php-scheduled-task.html