Jump to content

Php Link In Cron With Variables


dre2007

Recommended Posts

Is there somebody who can help me out with my issue?

I would like to start a cron job ( schedules task ) in linux which directs to a PHP website.

The link that has to load every 10 minutes is:

http://sub.domein.eu/cron/index.php?/Tickets/TicketsMinute/GeneralTasks

 

As you can see, after the "php?" it continues with: /Tickets/TicketsMinute/GeneralTasks

 

The cron job in ISPConfig doesn't execute the above ( entire link ) command, as I think the last part /Tickets/TicketsMinute/GeneralTasks is not being recognised as a URL.

 

If I enter the URL in my browser, everything works fine, so nothing is wrong with the script.

Would you please tell me what the part: /Tickets/TicketsMinute/GeneralTasks includes?

 

Any information would be appreciated and please be advised, I am a newb in PHP ( as you already discovered I assume :-) )

 

Thanks in advance.

Link to comment
Share on other sites

I'm pretty sure running PHP as a cron would probably be more in tune with running it as a CLI type script, this is kind of out of my area, but it would probably be best to run it as such.

 

The command would be: php {script_file_name} arg1 arg2 etc...

 

So maybe pass it as: php /path/to/index.php Tickets TicketMinute GeneralTasks

 

vardump $argv:

array(4) {
[0]=>
string(9) "index.php"
[1]=>
string(7) "Tickets"
[2]=>
string(12) "TicketMinute"
[3]=>
string(12) "GeneralTasks"
}

 

There may be other solutions, cURL perhaps? or other forum users may have better insight since I have yet to utilize cron jobs.

 

That and I am not sure if you plan on making the variables dynamic maybe?

Link to comment
Share on other sites

If the real problem is that the query string is being lost, double-check the crontab entry. A question mark may have a special meaning.

 

Running it as a CLI script would be better but you'd have to make a couple code changes if there isn't support for it already. You can't pass URL arguments into a command-line script directly; you'd have to grab them from $argv and set them manually. Actually you'd have to fake a few things, mostly in $_SERVER, if the code expects this to be an HTTP request.

Link to comment
Share on other sites

Hello DarkerAngel,

 

Thanks for the prompt reply, much appreciated.

However, as I am a noob I don't quite understand the above... Sorry

However, I fixed my problem.

I had to use wget from the CMD line in Linux: wget http://link.to.website.com/index.php?/Tickets/TicketsMinute/GeneralTasks

I kept trying it to run in ISPConfig but there is something wrong with that, ( I think a shell user has to be enabled ).

However, I will now manually add the WGET cronjob in Linux.

Well, I understand this is going off topic so if a moderator reads this then please feel free to remove it, else, I hope that someone else can do something with this information just like me. :D

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.