Jump to content

Cron variables


gerkintrigg

Recommended Posts

Fairly quick question about crons:

 

I want to send a variable to my cron script (which works btw), so I can make sure it's authorised to run like this:

 

Http://www.whatever.com/crons/my_script.php?auth_code=12345

 

Obviously that is the http address. Will it be different when I refer to the cron in the cron tab?

Link to comment
https://forums.phpfreaks.com/topic/282543-cron-variables/
Share on other sites

Why would you want cron to execute a php script via http? You should put your php script somewhere outside of the web accessible directory and call it via php's cli.

 

As for passing variables, if your going via http you have to use whatever mechanism http provides (such as that you have shown in your example).

Link to comment
https://forums.phpfreaks.com/topic/282543-cron-variables/#findComment-1451781
Share on other sites

Obviously that is the http address. Will it be different when I refer to the cron in the cron tab?

That depends on how exactly you run the cron job. If you just use wget/curl/lynx to fetch the URL, then no it won't be any different. If you run the script using the CLI version of PHP then yes, you'll need to handle the variables differently.

Link to comment
https://forums.phpfreaks.com/topic/282543-cron-variables/#findComment-1451785
Share on other sites

Okay so if I move it out of the accessible public_html folder then I use cli to refer to the cron a use some kind of variable send mechanism to plonk a variable into the script? I guess I'll look that up. Thanks.

 

FYI, the reason I'd use http is to run. Script that I DO want to access in the normal website life but do it as a scheduled event as well. It makes sense to only have one script doing one job. That's the whole point of database normalisation after all. ;-)

Link to comment
https://forums.phpfreaks.com/topic/282543-cron-variables/#findComment-1451786
Share on other sites

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.