Welcome to Dream.In.Code
Become a PHP Expert!

Join 150,172 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 2,231 people online right now. Registration is fast and FREE... Join Now!




cron alternative

 
Reply to this topicStart new topic

cron alternative

FliP1992
27 Aug, 2008 - 12:03 PM
Post #1

D.I.C Head
**

Joined: 14 Jun, 2007
Posts: 57


My Contributions
hello,

it says it all in the title realy, i need some queries to run every (minute, 5 minute's, hour and day)
the problem is my host only lets me run the minimum of every hour.

so im trying to find an alternative? (without switching host's)

my queries if you want to see them (since i have to paste some code)
CODE
$db->query("DELETE FROM fedjail WHERE fed_days=0");
$db->query("UPDATE users SET daysingang=daysingang+1 WHERE gang > 0");
$db->query("UPDATE users SET daysold=daysold+1, boxes_opened=0");
$db->query("UPDATE users SET mailban=mailban-1 WHERE mailban > 0");
$db->query("UPDATE users SET donatordays=donatordays-1 WHERE donatordays > 0");

User is offlineProfile CardPM
+Quote Post

mocker
RE: Cron Alternative
27 Aug, 2008 - 02:04 PM
Post #2

D.I.C Regular
Group Icon

Joined: 14 Oct, 2007
Posts: 290



Thanked: 17 times
Dream Kudos: 25
My Contributions
If you get a lot of hits on your site, you can store a timestamp somewhere, and then everytime your site gets hit, have it check if its been (5 minutes/1 minute/1 day) since the last timestamp and run the scripts. Otherwise you need to have a process that is continuously running and checking the system clock, just like cron does. Or you could get a host that doesn't suck
User is offlineProfile CardPM
+Quote Post

Computer_
RE: Cron Alternative
27 Aug, 2008 - 11:07 PM
Post #3

New D.I.C Head
*

Joined: 22 Aug, 2008
Posts: 16



Thanked: 1 times
My Contributions
If you're using MySQL and the version on the host is 5.1 (or 5.0 but I'm not sure about that) then you have to check this http://dev.mysql.com/doc/refman/5.1/en/events.html - the event schedular of MySQL.
Also you have to check from your host if they provide you access to this feature.

User is offlineProfile CardPM
+Quote Post

FliP1992
RE: Cron Alternative
28 Aug, 2008 - 02:27 AM
Post #4

D.I.C Head
**

Joined: 14 Jun, 2007
Posts: 57


My Contributions
no, sorry im on 5.0 i suppose i will just have to design a new way of health and stuff to regenerate
User is offlineProfile CardPM
+Quote Post

jonesa01
RE: Cron Alternative
31 Aug, 2008 - 12:18 AM
Post #5

New D.I.C Head
Group Icon

Joined: 18 Feb, 2007
Posts: 39


Dream Kudos: 25
My Contributions
QUOTE(FliP1992 @ 28 Aug, 2008 - 03:27 AM) *

no, sorry im on 5.0 i suppose i will just have to design a new way of health and stuff to regenerate


My suggestion is look here:

http://www.free-webhosts.com/free-cron.php, and see if they have more frequent crons.

If so you could sign up to them and use there cron, but still use your current host.

User is offlineProfile CardPM
+Quote Post

FliP1992
RE: Cron Alternative
31 Aug, 2008 - 02:32 AM
Post #6

D.I.C Head
**

Joined: 14 Jun, 2007
Posts: 57


My Contributions
ive been told that you could use this instead

CODE
<?php

if (($last + $interval) >= time()) {
// execute some script(s)
}

?>


could enyone explain it to help me understand it
User is offlineProfile CardPM
+Quote Post

jonesa01
RE: Cron Alternative
31 Aug, 2008 - 03:33 AM
Post #7

New D.I.C Head
Group Icon

Joined: 18 Feb, 2007
Posts: 39


Dream Kudos: 25
My Contributions
QUOTE(FliP1992 @ 31 Aug, 2008 - 03:32 AM) *

ive been told that you could use this instead

CODE
<?php

if (($last + $interval) >= time()) {
// execute some script(s)
}

?>


could enyone explain it to help me understand it


Yes I can,

basically it checks if the last execution added to the inteval is greater than the current time. If it is then the code is executed.


User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 03:22AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month