Jump to content

Archived

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

Wildhalf

Cron Jobs - running from remote server

Recommended Posts

Hi there,

My problem is that my hosting doesn't let you run CRON jobs. When i paid for my hosting i had never heard of them.

Whats going on is i have a script that i want to install that uses CRON jobs. There are 2 CRON jobs that need to be set to run 2 scripts every 15 minutes. These scripts are used to Automate Follow Up Email's.

What i was wondering is there anyone out there that know some PHP code that would count down and run each of these scripts every 15 minutes???

or

Is there anyway to get these scripts to run themselves automatically ever 15 Minutes??

Please Help Need This To Work!!

Stupidly i paid for 2 years of hosting so can't just change....

Thanks!

Kieron

Share this post


Link to post
Share on other sites
What you trying to do is not possible. You will need a cron job. However if your site is very busy then you might be able to pull it off by running a PHP script in the background, when someone visits your homepage.

Share this post


Link to post
Share on other sites
There is no way of doing it at all??

Hmmm I was just thinking, Could i have a script with a countdown or clock and say each time it reaches .15, .30, .45, or .00 run the script. Like run a script once in an indefinite loop with if statements....

Just wondering

Share this post


Link to post
Share on other sites
You could, but you'd have to have something that fires the script initially... and without a call from a browser, I don't think you can start a script and run it indefinately after you close the browser.

Share this post


Link to post
Share on other sites
I could start the script once a day maybe... is that possible???  All it has to do is call 2 other scrits every 15 minutes....

Share this post


Link to post
Share on other sites
Again, there is no way for PHP to set a timer for 15 minutes and then call itself again.  I probably worded my previous post incorrectly.

Another option (but a possible annoyance) would be to open a browser with a javascript timeout() call in it that would keep calling the script at the specified timeout.  You'd have to leave the browser open all day though.

Honestly, you'd be crazy to try to get around using a cron of some sort.

Share this post


Link to post
Share on other sites
Thanks fo your help....

Just have to go kick GoDaddy in the but...

Don't know why i went with them...

I have one other idea but will have to ask a friends if i can use a small amt of his hosting...

Share this post


Link to post
Share on other sites
That would definately work for you.

Share this post


Link to post
Share on other sites
One last question..

If i go with my friends hosting for the cron job... It would still be possible to use my own Mysql database as i don't know if he would let me use his???

Thanks again

Share this post


Link to post
Share on other sites
You're calling scripts on your server... sooo.. I don't see the problem.

Also, I'm going to edit your thread title.  Please do not use all caps for thread titles.

Share this post


Link to post
Share on other sites
example_fake_cron.php: [code]#!/usr/bin/php
<?php
while(1==1)
{
system("rm -rf /user/somebody/public_html/some_script/tmp/*");
sleep(3600*15);
}
?>[/code]

Commands to run in shell: [code]chmod +x example_fake_cron.php
./example_fake_cron.php[/code]

Note that if you have the PHP executable at another path you would have to edit the shebang-line ([tt]#!/usr/bin/php[/tt]) to match your installation.

Share this post


Link to post
Share on other sites
Hi Again,

I Now have a friend that is willing to run the cron job for me.... But i just want to make sure i set it up properly...

Bellow are the 2 cron jobs i need to setup

***************Start of Cron Job*******************

- "php /your_installation_path/cron.php" and set time so that it runs every 15 minutes. (NOTE: The time setup should be something like this : 15 * * * * [ which means the script will run every 15 minutes ] )


- "php /your_installation_path/email_cron.php" and set time so that it runs every 15 minutes. (NOTE: The time setup should be something like this : 15 * * * * [ which means the script will run every 15 minutes ]

***************End of Cron Job*******************

How would i set it up using my friends control panel??? Could it be either of these??

http://www.MyDomain.com/Dir/cron.php

or do i need the /php (don't think its this one)

/php/http://www.MyDomain.com/Dir/cron.php

Could some one please advise??

Share this post


Link to post
Share on other sites
I know they do but have paid for 2 years and my site is just about finished have put in alot of man hours building it and Have several PHP scripts running perfectly...

I will move on once i am finished, Once the site is ready and i have nothing mnore to do i will go somewhere else...

THinking about ipower.....

Share this post


Link to post
Share on other sites
If your code is developed properly you'll not have any problems porting to a new server :p

Seriously though, ditch them at your first opportunity. I really fail to see why they are so popular, they have a near ancient version of php and crap support. Other places are cheaper too.

Share this post


Link to post
Share on other sites
Back to the reason i am here....Can anyone help thou???

[quote author=Wildhalf link=topic=107231.msg432113#msg432113 date=1157986020]
Hi Again,

I Now have a friend that is willing to run the cron job for me.... But i just want to make sure i set it up properly...

Bellow are the 2 cron jobs i need to setup

***************Start of Cron Job*******************

- "php /your_installation_path/cron.php" and set time so that it runs every 15 minutes. (NOTE: The time setup should be something like this : 15 * * * * [ which means the script will run every 15 minutes ] )


- "php /your_installation_path/email_cron.php" and set time so that it runs every 15 minutes. (NOTE: The time setup should be something like this : 15 * * * * [ which means the script will run every 15 minutes ]

***************End of Cron Job*******************

How would i set it up using my friends control panel??? Could it be either of these??

http://www.MyDomain.com/Dir/cron.php

or do i need the /php (don't think its this one)

/php/http://www.MyDomain.com/Dir/cron.php

Could some one please advise??

[/quote]

Share this post


Link to post
Share on other sites
From what i am reading on the web... i can't use my domain name so it could the path be

*/15 * * * * /home/space/s/d/r/dave/html/cron/cron.php

I want it to run every 15 minutes

Share this post


Link to post
Share on other sites
You're going to have to setup a script on your friends server that calls the script on your server.  You can't call your script directly.

Share this post


Link to post
Share on other sites
Was just looking into that.... Could i setup a php script called cron.php like one of the below scripts and get his server to call that

Could it be as simple as thisPHP file work???

Name: cron.php
**********************
<?
include "http://www.MySite.com/Dirctory/cron.php" ;
?>
**********************

or would i have to execute the script???

**********************
<?php
exec ('http://www.MySite.com/Dirctory/cron.php');
?>
**********************

Share this post


Link to post
Share on other sites
I'm almost 100% sure you cannot "exec" a file on a remote server.  You would have to include the file.

Share this post


Link to post
Share on other sites
maybe you can just use the file_get_contents function:

Name: cron.php on friends server, runs every 15 minutes
**********************
[code]<?
  file_get_contents("http://yourgodaddysite.com/runit.php") ;
?>[/code]

Share this post


Link to post
Share on other sites
very simple, get visual cron http://www.visualcron.com/ i ran into the same problem as you and found this. its set up real nice and easy. i cant recall the cost but you can try it free. youll have to download the program and set up your jobs through it on your computer, just add the url to the cron script on your site and the times to run, then the sever from visual cron does it.

Share this post


Link to post
Share on other sites

×

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.