Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 16 Dec 2014, 17:36
Mko's Avatar
Mko Mko is offline
 
Join Date: May 2009
Real name: Mark
Scheduled Task - Run Every 5 Seconds

I've created a Scheduled Task that will submit a request to an API and store the value returned in a table in my database.
I'm interested in having this Scheduled Task run every 5 seconds, yet in the vB3 AdminCP, the only fields I see are Day of the Week, Day of the Month, Hour, and Minute. However, Minute has 6 fields attributed to it, which I am also confused about.

How would I get my Scheduled Task to run every 5 seconds through vBulletin?


Thanks,
Mark
Reply With Quote
  #2  
Old 16 Dec 2014, 17:45
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
There are 6 "minute" fields because you can schedule a task to run up to 6 times per hour at certain minutes of the hour. If you choose '*' then it will run once per minute, but that's the most often you can schedule a task to run (unless you modify the code somehow).

I'm assuming that you're using the returned value somewhere, maybe you could do something like before it's displayed check to see if it's more than 5 seconds old, and if it is, request it before displaying it. But then I guess you'd also need a way to keep it from constantly being requested by multiple threads, especially if you have a very busy site,
Reply With Quote
  #3  
Old 16 Dec 2014, 17:54
Mko's Avatar
Mko Mko is offline
 
Join Date: May 2009
Real name: Mark
Originally Posted by kh99 View Post
There are 6 "minute" fields because you can schedule a task to run up to 6 times per hour at certain minutes of the hour. If you choose '*' then it will run once per minute, but that's the most often you can schedule a task to run (unless you modify the code somehow).

I'm assuming that you're using the returned value somewhere, maybe you could do something like before it's displayed check to see if it's more than 5 seconds old, and if it is, request it before displaying it. But then I guess you'd also need a way to keep it from constantly being requested by multiple threads, especially if you have a very busy site,
I see. Thanks for the suggestion!

Would the following settings be what I'm after if I wish to have my Task run every minute?
Reply With Quote
  #4  
Old 16 Dec 2014, 17:59
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Yes, I believe that would do it.

But in case you're not aware, the tasks run when users view your forum pages, so the timing it approximate, and it will only run once per minute if you have enough traffic to your site.
Reply With Quote
  #5  
Old 16 Dec 2014, 18:00
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Real name: Lynne
That should do it. Be aware that the Scheduled Tasks only run if you have users on your site. The tasks will backup if you don't have people clicking on your site.
__________________
Former vBulletin.org Staff Member

Try a search before posting for help. Many users won't, and don't, help if the question has been answered several times before.
W3Schools -
Online vBulletin Manual
If I post some CSS and don't say where it goes, put it in the additional.css template.
I will NOT help via PM (you will be directed to post in the forums for help.)
Reply With Quote
  #6  
Old 16 Dec 2014, 18:24
Mko's Avatar
Mko Mko is offline
 
Join Date: May 2009
Real name: Mark
I see! Thanks for the information.

As a follow-up question...
I have a custom bridge I developed with vB. Since both you reminded me how a user needs to be viewing the forum in order for Scheduled Tasks to execute, I decided to generate $cronimage in my site-wide header (not present on my directory with my vBulletin files) so that Scheduled Tasks hopefully would execute even if nobody is viewing the Forum Index.

Here is what I included (community/ is the directory where I have my vBulletin):

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

It outputs correctly, but I just want to double check that this is the proper way of "inducing" Scheduled Tasks to run from an external page.

Thanks again!
Reply With Quote
  #7  
Old 16 Dec 2014, 19:11
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
It seems right, but to be honest I don't know for sure.
Reply With Quote
  #8  
Old 16 Dec 2014, 23:37
ozzy47's Avatar
ozzy47 ozzy47 is offline
 
Join Date: Aug 2009
Real name: Chris
Yeah it looks ok to me also. But I don't understand, what is it you need to run so often?
__________________
You can get access to my 180 mods for vB 3.6 - 4.x at The Admin Zone as well as the professional support you are used to. New vBulletin Spider Definitions, vBulletin Spiders List Hits 1000 Spiders! ​ OzzModz down. Site has had a data breach, checking how the intrusion happened. Change your PW if you use the same one on my site and others.
Reply With Quote
  #9  
Old 17 Dec 2014, 00:19
Mko's Avatar
Mko Mko is offline
 
Join Date: May 2009
Real name: Mark
Originally Posted by ozzy47 View Post
Yeah it looks ok to me also. But I don't understand, what is it you need to run so often?
I was initially going to call the API to fetch the amount of players logged in, but I opted to do it using a table in my db and not using a Scheduled Task.

Anyways, good to see that the code I added in the header looks OK. Thanks for all the help!
Reply With Quote
  #10  
Old 17 Dec 2014, 00:23
ozzy47's Avatar
ozzy47 ozzy47 is offline
 
Join Date: Aug 2009
Real name: Chris
Gotcha. Glad to see you found a way to do what you wanted though.
__________________
You can get access to my 180 mods for vB 3.6 - 4.x at The Admin Zone as well as the professional support you are used to. New vBulletin Spider Definitions, vBulletin Spiders List Hits 1000 Spiders! ​ OzzModz down. Site has had a data breach, checking how the intrusion happened. Change your PW if you use the same one on my site and others.
Reply With Quote
  #11  
Old 17 Dec 2014, 02:15
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Real name: Paul M
Originally Posted by Mko View Post
so that Scheduled Tasks hopefully would execute even if nobody is viewing the Forum Index.
The default vb cron does not rely on someone viewing the forum index, it is part of the footer, so runs off any page.
__________________
Former vBulletin.org Staff Member


Cable Forum
Please do not PM me about custom work - I no longer undertake any.
Note: I will not answer support questions via e-mail or PM - please use the relevant thread or forum.
Reply With Quote
  #12  
Old 17 Dec 2014, 12:24
ozzy47's Avatar
ozzy47 ozzy47 is offline
 
Join Date: Aug 2009
Real name: Chris
This is true, unless of course it is a custom page, and you did not include the footer on it.
__________________
You can get access to my 180 mods for vB 3.6 - 4.x at The Admin Zone as well as the professional support you are used to. New vBulletin Spider Definitions, vBulletin Spiders List Hits 1000 Spiders! ​ OzzModz down. Site has had a data breach, checking how the intrusion happened. Change your PW if you use the same one on my site and others.
Reply With Quote
  #13  
Old 27 Jun 2015, 10:03
Easy5s.net Easy5s.net is offline
 
Join Date: Jun 2011
Please let me know, I've set up a cron to run every minute as above. If no one is accessing the site, the cron does not run?
Reply With Quote
  #14  
Old 27 Jun 2015, 12:16
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Originally Posted by Easy5s.net View Post
Please let me know, I've set up a cron to run every minute as above. If no one is accessing the site, the cron does not run?
That's correct, it won't run if no one is accessing the site. There has been mention before of using an actual cron job to run the scheduled tasks. If you search here and at vbulletin.com you should find something about it. I can't remember the details but it might have been as easy as setting it up to run the cron.php script.
Reply With Quote
  #15  
Old 27 Jun 2015, 15:10
Easy5s.net Easy5s.net is offline
 
Join Date: Jun 2011
I have search more one 1h in vb.com but not find
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 15:47.

Layout Options | Width: Wide Color: