iversonm Posted May 13, 2010 Share Posted May 13, 2010 Ok so my crontab works fine but i need to set a variable either through the url query string or post. my command line is /var/www/CronJobs/Blah.php?Variable=Foo So when the Blah.php page is loaded with crontab $_GET['Variable'] will == Foo. How can i go about doing this, doesnt matter if it through sessions, get, post. Much appreciated Link to comment https://forums.phpfreaks.com/topic/201577-crontab-and-php-variables/ Share on other sites More sharing options...
trq Posted May 13, 2010 Share Posted May 13, 2010 cli script accept arguments, not post or get data. So, your call would look like.... /var/www/CronJobs/Blah.php Foo and your argument will show up within the $argv array. Tale a look at the man page for cli for more info. Link to comment https://forums.phpfreaks.com/topic/201577-crontab-and-php-variables/#findComment-1057505 Share on other sites More sharing options...
kenrbnsn Posted May 13, 2010 Share Posted May 13, 2010 When you execute PHP from the command line, the $_GET array doesn't exist, but you can pass parameters on the command line and retrieve them from the $argv array. $argv[0] is the php.file $argv[1] is the first parameter $argv[2] the second an on and on So you would have in the crontab /var/www/CronJobs/Blah.php Foo and "Foo" would be in $argv[1] Ken Link to comment https://forums.phpfreaks.com/topic/201577-crontab-and-php-variables/#findComment-1057506 Share on other sites More sharing options...
iversonm Posted May 13, 2010 Author Share Posted May 13, 2010 Thanks guys, I really appreciate it. Problem solved. I will let you know if i have anymore problems. Link to comment https://forums.phpfreaks.com/topic/201577-crontab-and-php-variables/#findComment-1057517 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.