Jump to content

cron jobs, setting the script name to be dynamic? (read this one carefully!)


dsaba

Recommended Posts

I'm going to try to explain what i want to do, to the best of my ability. So read carefully.

 

I want to setup a cronjob to run a certain script, nothing different here.

Normally you have to specify a url to the script and the script name, in order for the cron to run it.

From my understanding the "cron" which does the "job" is a machine a server, with an ip..etc...

This machine can run certain commands to execute and do different things.

I want to make my script url dynamic by saying "http://urltoscript.php?time=CRONCOMMANDFORTIME"

 

I know that this machine called the "cron" can execute a command to call a timestamp or read the current time..whatever

 

I simply want to have it call the timestamp and echo it as part of the script url that is supposed to execute

 

 

Is this possible? and if so could you show me a basic code to do this in "cron code"

 

 

my second question is if this "cron" is indeed a machine or a server, does it accept cookies and sessions like a normal user surfing the web does?

 

-thank you

cron does not accept cookies and sessions.  It just runs programs at a specific time, that's it.  It's very simple and dumb.

 

The simple solution is to have cron call a wrapper php script, and have that php script call the real script (the one on your url) with whatever arguments you want to pass along to it.  Then you have the full flexibility of php available to you.

i was thinking of that btherl

 

BUT how exactly would this php script wrapper work?

how would i make that php script load another php script?

 

would I use file_getcontents ??

 

what code would i put in that script wrapper?

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.