Announcement

Collapse
No announcement yet.

[SOLUTION] How to get Scheduled Tasks to run regularly

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Wayne Luke
    commented on 's reply
    We prefer that every customer open their own topic on any subject rather than pollute an existing topic with something that may be unrelated. It prevents confusion when providing support. Both for the customer and the support staff.

    Your host's crontab system and vBulletin's Scheduled Task System are unrelated. The Scheduled Task system deployed by a standard vBulletin installation relies on visitor traffic and it will run one task per visitor every 5 minutes. This prevents any task related slowdown to the end user. Any additional tasks that trigger at that time, are added to a queue and called with the next 5 minute block. If you have visitors every 5 minutes, the system stays relatively on track. However, none of the tasks are considered time critical so if they are off by a few minutes then they won't cause any damage.

    The vbcron.php file allows you to bypass the default system and call these tasks from crontab without traffic to your site or if you want to alleviate some of the resources used by Web PHP. This setup is optional since not every vBulletin customer has access to their server's task system (i.e. crontab).

  • dirknerkle
    commented on 's reply
    My host doesn't allow willy-nilly crontab options but instead, they provide several settings (daily, hourly, etc.) so that there's some consistency in setting up cron jobs. The host's settings are likely at odds with the timing in vB5's settings, so it's probably that the two control systems may never be in sync. However, I've set the vB5 scheduled tasks (for batch emailing) to run every minute and I've set the host's timer to run the vbcron.php module every 5 minutes, with the thinking that the two ought to be in sync twelve times every hour, which seems plenty frequent for sending batches of emails. We're currently testing whether this works... It just seems that vB5 ought to have a more elegant solution than this....

  • dirknerkle
    commented on 's reply
    Thanks! I'll check that out.

    Yes, indeed it was an old thread. I've always reasoned that it's better to append to an existing thread that matches your question vs. yet another thread of exactly the same topic. After 3 years with no activity, I usually dump them into an archive.

  • Wayne Luke
    replied
    It is generally rare that a three year old topic is still valid. In those three years, hundreds of issues have been resolved and features added to the software. Changes are often made because of challenges like these.

    You can call them from your server's crontab daemon using the vbcron.php in your do_not_upload folder. Configuration instructions are in the file. Just upload it outside your web directory and call it with crontab.

    Leave a comment:


  • dirknerkle
    replied
    Good grief, is this still true? Does vB5's scheduled tasks settings not work as prescribed but instead need to be triggered externally?

    I'm finding the only way I can get any of the tasks to run is to invoke them manually. Is this by design or is it a bug -- and a pretty big bug at that???

    Leave a comment:


  • Wayne Luke
    replied
    Originally posted by cybergods View Post
    NOTICE: Do not, under ANY circumstances, set the refresh to any value LOWER than "60". If you do there may not be enough time for you to edit and save the page before it refreshes. Setting it to any time under 5 seconds will mean that you will most likely be unable to even do a fast page delete.

    When working on this page I recommend first editing the page, setting the refresh rate to "6000" and saving the page again. You can then re-edit the page and work on it without fear of it refreshing in the middle of your work. Re-set the timer when you are finally done.

    Again, this is kludgy and nasty - but it works, If anyone has a better solution -- please let me know

    Thanks
    You can disable the parsing of Static HTML modules under Settings -> Options -> General Settings. This will allow you to access the page if the refresh interval is too low. However, Scheduled tasks run on a minute interval at the most so a value under 60 isn't really beneficial and just uses resources.

    Though, if you have access to CRON jobs on your server you might simply want to call a script that uses wget to load the page and then delete it. Call it every minute or five minutes. Then you don't need to keep a browser window open all the time.

    Code:
    wget http[s]://domain.com/path/to/vbulletin/index.php
    rm index.php

    Leave a comment:


  • cybergods
    started a topic [SOLUTION] How to get Scheduled Tasks to run regularly

    [SOLUTION] How to get Scheduled Tasks to run regularly

    As you know vBulletin uses the page-load of users to run cron.php thus kicking off scheduled tasks. On boards without a lot of regular users this means it may be hours before the next scheduled task runs.

    I've tried to find a solution to get the system cron to run cron.php, however with v5 of VB all I get is an "AccessDenied". If anybody knows how to get the system cron to work, please let me know as it is more elegant and desirable than my kludge.

    In any event, I've created the following kludge to run cron.php every minute (or any schedule you want). This kludge is ugly and stupid, but I can't figure out a good work-around to this problem and, it seems, that real cron support is still far in the future for v5 of VB.
    • First, using Site Builder, create a new page
    • Insert a "Static HTML" module and nothing else on the page
    • Edit the module and insert the following:


    HTML Code:
    <META HTTP-EQUIV="refresh" CONTENT="60">
    
    <h1>Refresh<h1>
    
    <label id="minutes">00</label>:<label id="seconds">00</label>
        <script type="text/javascript">
            var minutesLabel = document.getElementById("minutes");
            var secondsLabel = document.getElementById("seconds");
            var totalSeconds = 0;
            setInterval(setTime, 1000);
    
            function setTime()
            {
                ++totalSeconds;
                secondsLabel.innerHTML = pad(totalSeconds%60);
                minutesLabel.innerHTML = pad(parseInt(totalSeconds/60));
            }
    
            function pad(val)
            {
                var valString = val + "";
                if(valString.length < 2)
                {
                    return "0" + valString;
                }
                else
                {
                    return valString;
                }
            }
        </script>
    Set the "60" in the first line to the time interval you want to use for a page refresh, save the page but do not add it to any user-viewable menu.

    To use this just use a browser and open this page. It will automatically refresh every 60 seconds and do a count-up timer to 1 minute for a visual clue that the thing is working.

    If you open this in a new browser window, you can minimize the window and it will continue to work unattended.

    NOTICE: Do not, under ANY circumstances, set the refresh to any value LOWER than "60". If you do there may not be enough time for you to edit and save the page before it refreshes. Setting it to any time under 5 seconds will mean that you will most likely be unable to even do a fast page delete.

    When working on this page I recommend first editing the page, setting the refresh rate to "6000" and saving the page again. You can then re-edit the page and work on it without fear of it refreshing in the middle of your work. Re-set the timer when you are finally done.

    Again, this is kludgy and nasty - but it works, If anyone has a better solution -- please let me know

    Thanks

Related Topics

Collapse

Working...
X