Jump to content

Crontab and Php variables


iversonm

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.