Announcement

Collapse
No announcement yet.

New Feature: Scheduled Tasks By File In vB 5.3.4

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

  • New Feature: Scheduled Tasks By File In vB 5.3.4

    Today I'll upgrade vB to 5.3.4, In announcement you inform about an added file for scheduled tasks.
    Added an external file that allows the running of Scheduled Tasks via the server's cron/scheduled task system. This will allow separation of these tasks from the web server.
    Questions:
    1. What is this file named?
    2. Can you please show an example, how to use it?

  • #2
    It's vbcron.php located in the "Do Not Upload" folder. The instructions are included in the file itself.

    1. Copy the script to your webserver. Preferable outside of the webroot directory.
    2. Set the $core variable to the path to your vb core directory
    3. Add an entry to your system cron to run the script (recommend running every minute)
    /path/to/php /path/to/file/vbcron.php

    Comment


    • #3
      Thank you In Omnibus, that will help me.

      Looks like this file runs all available cron jobs. So should I deactivate scheduled tasks by php in AdminCP ?

      Comment


      • #4
        Originally posted by BulliM View Post
        Thank you In Omnibus, that will help me.

        Looks like this file runs all available cron jobs. So should I deactivate scheduled tasks by php in AdminCP ?
        Support staff could answer this better than I can but it seems you'd not want the same cron jobs running simultaneously from two different scripts when they are running every 60 seconds.

        It would seem like if you run a cron job from vbcron.php you should turn off the same cron job in the admincp.

        Comment


        • #5
          But that file seems to check, if cron jobs are enabled in AdminCP. I'll ask that in official release discussion topic. https://www.vbulletin.com/forum/foru...ase-here/page3

          Comment


          • #6
            You should not touch the scheduled tasks in the AdminCP. All vbcron.php does is trigger the API to run the scheduled tasks as they are defined in the AdminCP. It simply removes the need for someone to visit your site every minute to run them regularly.

            On the server level, you just need to set up a crontab to run php /path/to/vbcron.php.
            Translations provided by Google.

            Wayne Luke
            The Rabid Badger - a vBulletin Cloud demonstration site.
            vBulletin 5 API

            Comment


            • #7
              Originally posted by Wayne Luke View Post
              You should not touch the scheduled tasks in the AdminCP.
              That's what I thought. Thank you Wayne Luke!

              Comment


              • #8
                Just FYI...I confirmed with Kevin at http://tracker.vbulletin.com/browse/VBV-17997 that you can optionally turn off the cron AJAX call if you set up the external vbcron.php. It's at AdminCP > Settings > Options > Server Settings and Optimizations Options > Enable Scheduled Tasks. That option only affects the cron AJAX call and the system cron will still be able to run all the active tasks according to schedule.

                GIPHY for vB5 AutoLinker Auto-Create Flag Report Topic Social Icons in Postbit Clear Cache Cron DragDrop Upload Topic AJAX AutoUpdate Custom Avatars Selector Stop Links in Posts...and more!

                Comment


                • BulliM
                  BulliM
                  Senior Member
                  BulliM commented
                  Editing a comment
                  Thats a valuable information. So I do turn off scheduled tasks, because I also run vbcron by cronjob. I can say, that's a lot better, because all my scheduled tasks are running now quite fine.

              • #9
                So I'm about 3 years late in answering this, but hopefully my addition will help someone.

                Here's my crontab file:

                Code:
                SHELL=/bin/bash
                PATH=/sbin:/bin:/usr/sbin:/usr/bin
                MAILTO=root
                
                # For details see man 4 crontabs
                
                # Example of job definition:
                # .---------------- minute (0 - 59)
                # | .------------- hour (0 - 23)
                # | | .---------- day of month (1 - 31)
                # | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
                # | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
                # | | | | |
                # * * * * * user-name command to be executed
                0 23 * * * root some task
                1 1 * * * root some task
                5 1 * * * root some task
                
                MAILTO=""
                * * * * * root php /root/scripts/xx-vbcron.php > /dev/null
                * * * * * root ( sleep 15 ; php /root/scripts/xx-vbcron.php > /dev/null )
                * * * * * root ( sleep 30 ; php /root/scripts/xx-vbcron.php > /dev/null )
                * * * * * root ( sleep 45 ; php /root/scripts/xx-vbcron.php > /dev/null )
                * * * * * root php /root/scripts/aa-vbcron.php > /dev/null
                * * * * * root ( sleep 15 ; php /root/scripts/aa-vbcron.php > /dev/null )
                * * * * * root ( sleep 30 ; php /root/scripts/aa-vbcron.php > /dev/null )
                * * * * * root ( sleep 45 ; php /root/scripts/aa-vbcron.php > /dev/null )
                Notice the 2nd MAILTO - this stops the vbcron task from sending mail to root - since I'm running this every 15-seconds, I don't want a bunch of extraneous mails.
                Notice the > /dev/null at the end - this stops the logs from getting full of stuff I don't care about.

                The vbcron has been renamed since I have multiple websites on this server, I need to have one per domain because I have to give each script the path to my core for that domain.
                The sleep delays each instance by 15 seconds so I run 4 per minute per domain. This is no more resources than online users in your forum switching pages once/15-seconds.

                If your site is really busy you won't need this, but for a site that's just starting up this works very well.

                You can adjust the times to do every 30-seconds instead of every 15 - whatever is good for your needs.

                BTW: This works in v5.5.6 without issue.

                I hope this helps some of you.
                cybergods
                New Member
                Last edited by cybergods; Sun 9 Feb '20, 1:33pm.

                Comment


                • BulliM
                  BulliM
                  Senior Member
                  BulliM commented
                  Editing a comment
                  Think, that is too often, because some cron jobs needs more than 10 seconds to be done. Trigger cronjob every minute one time is enough. You should ask
                  Wayne Luke
                  vBulletin Technical Support Lead
                  Wayne Luke for.

                • Wayne Luke
                  Wayne Luke
                  vBulletin Technical Support Lead
                  Wayne Luke commented
                  Editing a comment
                  Scheduled tasks are queued in vBulletin. Running vb_cron.php will trigger a queued script and run it until its completion. Triggering it again shouldn't affect scripts already running. However, you may end up with a number of scheduled tasks running at once. Though this should still use fewer resources than triggering the tasks from the web interface with a page load.

              Related Topics

              Collapse

              Working...
              X