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
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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.