Jump to content


Photo

Cron Jobs - running from remote server


  • Please log in to reply
23 replies to this topic

#1 Wildhalf

Wildhalf
  • Members
  • PipPipPip
  • Advanced Member
  • 101 posts

Posted 07 September 2006 - 02:00 PM

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

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 07 September 2006 - 02:10 PM

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.

#3 Wildhalf

Wildhalf
  • Members
  • PipPipPip
  • Advanced Member
  • 101 posts

Posted 07 September 2006 - 02:14 PM

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

#4 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 07 September 2006 - 02:23 PM

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.

Info: PHP Manual


#5 Wildhalf

Wildhalf
  • Members
  • PipPipPip
  • Advanced Member
  • 101 posts

Posted 07 September 2006 - 02:28 PM

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

#6 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 07 September 2006 - 02:30 PM

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.

Info: PHP Manual


#7 Wildhalf

Wildhalf
  • Members
  • PipPipPip
  • Advanced Member
  • 101 posts

Posted 07 September 2006 - 02:33 PM

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

#8 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 07 September 2006 - 02:36 PM

That would definately work for you.

Info: PHP Manual


#9 Wildhalf

Wildhalf
  • Members
  • PipPipPip
  • Advanced Member
  • 101 posts

Posted 07 September 2006 - 02:48 PM

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

#10 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 07 September 2006 - 02:59 PM

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.

Info: PHP Manual


#11 Wildhalf

Wildhalf
  • Members
  • PipPipPip
  • Advanced Member
  • 101 posts

Posted 07 September 2006 - 03:12 PM

Sorry about that!!

THanks again

#12 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 07 September 2006 - 06:39 PM

example_fake_cron.php:
#!/usr/bin/php
<?php
while(1==1)
{
	system("rm -rf /user/somebody/public_html/some_script/tmp/*");
	sleep(3600*15);
}
?>

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

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

#13 Wildhalf

Wildhalf
  • Members
  • PipPipPip
  • Advanced Member
  • 101 posts

Posted 11 September 2006 - 02:47 PM

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??


#14 Jenk

Jenk
  • Members
  • PipPipPip
  • Advanced Member
  • 778 posts

Posted 11 September 2006 - 02:50 PM

Just cancel your sub with GoDaddy. They suck.

#15 Wildhalf

Wildhalf
  • Members
  • PipPipPip
  • Advanced Member
  • 101 posts

Posted 11 September 2006 - 02:52 PM

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

#16 Jenk

Jenk
  • Members
  • PipPipPip
  • Advanced Member
  • 778 posts

Posted 11 September 2006 - 03:16 PM

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.

#17 Wildhalf

Wildhalf
  • Members
  • PipPipPip
  • Advanced Member
  • 101 posts

Posted 11 September 2006 - 03:21 PM

Back to the reason i am here....Can anyone help thou???

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??



#18 Wildhalf

Wildhalf
  • Members
  • PipPipPip
  • Advanced Member
  • 101 posts

Posted 11 September 2006 - 03:40 PM

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

#19 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 11 September 2006 - 03:52 PM

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.

Info: PHP Manual


#20 Wildhalf

Wildhalf
  • Members
  • PipPipPip
  • Advanced Member
  • 101 posts

Posted 11 September 2006 - 04:01 PM

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.co...ctory/cron.php" ;
?>
**********************

or would i have to execute the script???

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users