Crons - Every 5 Minutes Limit at My Web Host


With my web host, I’m able to run a cron at an interval of 5 minutes, not any shorter.

I’m developing a Twitter application and I need to run a PHP script, say every minute, to retrieve new data.

Since I cannot run a 1-min-cron, what else can I do?

A reliable pingdom-like service that visits a page every minute (but from just one location preferably, not multiple locations) would do the trick. But is there one?



If you’re not worried about keeping a visitor “up to date,” why worry when you can always go grab what you need when they request your script? Sorry, I had to make that leap of faith to believe that you wanted to keep the “live” connection going.

No worries! In fact, my “why bother” was more from my not believing that Twit, etc, serves no useful purpose.




I have written some scripts which rely on PHP to set the stage but use JavaScript for the interval timer (e.g. setInterval(‘updateClock(startjs)’,1000); to update a clock on the page every second. A “chat’s” textarea was updated off the server every 10 seconds with setTimeout(‘updateMsg()’, 10000); which used AJAX to query a PHP script for new posts in the database. I think that an HTML or PHP page can run indefinitely (on a browser) which can update your … well, whatever, via AJAX requests and DHTML (jQuery makes this pretty simple). Isn’t this what you’re looking for?



Hi Glenn,

You’re giving tweeters credit for … well, I won’t get into that! However, if they don’t send the message via your app, how can they expect your app to know about it instantly - unless they query you (er, your app) in which case it KNOWS to check for an update. I think you’re correct, you DON’T NEED the cron at all!



If I were you, I would NOT run a cron job to post every 5 minutes. you’re going to drive your server into the ground, and you don’t wanna look spammy to search engines


I have also coded an AJAX chatbox from scratch (no jQuery) a few years ago, so I think I know what you’re talking about.

In this case, where is that browser page supposed to be open at all times?

But any way the end result is similar with the one i my previous post: Have a 5min-cron plus a little code snippet (server-side) on every page that checks time and runs the updater if needed. So that:

-If no traffic we make sure new data from Twitter will be fetched anyway.
-If there is trafffic it will be updated every 1 min.

At this point, we don’t need to update the page that is open via AJAX.

Looking at my initial question, now I think this is not a problem at all, unless you critically need instant data updates that is to be fetched from Twitter.

Thanks David , it helped to have your point of view.

Another option is to have a 5-min cron. Then add a function to front-end pages of the application which checks 1 min intervals (or even shorter, or even the last mention id from Twitter!) and runs the cron script if needed.

This seems to be the best, as database will still be updated every 5 mins when there is not website traffic. Plus it will be updated more frequently (or instantly) when there is traffic.


  1. There is also a max. cronjob limit which is 5. So I do not want to waste them.

  2. The script does not have any front end. Just collects data and updates the database.

  3. Hm, I don’t know what this is. I have to look what does that mean. If this is browser refresh you are talking about well again, script has no front end.

  4. This could be an option. Another limit is max script runtime which is 5 min too. I don’t know what happens when I hang a script with sleeps or something.

  5. The thing is Twitter users will be able to interact with the app, without even following or authenticating the application.

They’ll just post regular tweets with @appname from their Twitter accounts.

And this script we are talking about, will collect and process those ‘mentions’. Not instantly maybe but as quickly and timely as possible.

Hi Glenn,

Hmmm, how to get around a 5 minute limit to get one minute timing?

  1. 5 separate cron jobs starting a minute apart with 5 minute cycle time.

  2. Javascript page using AJAX on an “interval” timer.

  3. HTML “refresh”.

  4. PHP script with a “timer” which header(“Location: …”) links to itself every minute.

  5. Analyze whether a one minute cycle time is really necessary.

I’d probably look at #5 first as that looks pretty nasty on server resources.



if they don’t send the message via your app, how can they expect your app to know about it instantly

Believe me, most will probably expect it :slight_smile: They’ll think, where is my entry that I just tweeted.

By the way, the application is loosely similar to

I guess I’ll run a cron but maybe not that frequent 'cos I’ll go with the solution I mentioned previously above.

The server will do fine anyway, the script does not post any tweets at all and it’s not going to do anything that would look spammy.

My main concern is this:

A Twitter user sends a regular tweet mentioning the application (using @appname). Not from the application interface or something: from or from any other Twitter client of his choice.

Now just after tweeting, he would expect to see the result/effect of his tweet instantly (not after 1 min or so), if he visits the website of the application.

We can of course query the Twitter database for every single pageview but this is most likely unnecessary and not good for server overload, especially if there are lots of users browsing the website simultaneously (think tens or hundreds of API requests to Twitter in a very short period of time).

[SIZE=“1”]I’ll summarize again how application works briefly below:

  1. Users tweet in a specific format mentioning @appname in the tweet. (Signing up or authorizing the application is not needed at all.)
  2. A data collecter script, checks Twitter database from time to time, via Twitter API and gets new tweets, validates them and adds them to the application database.
  3. This data is displayed in the application website.[/SIZE]