Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #6  
Old 08-18-2011, 06:58 PM
EquinoxWorld EquinoxWorld is offline
 
Join Date: Nov 2009
Location: Naples
Posts: 354
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by nhawk View Post
I see...

I do believe the nextrun is calculated after the run is complete. I could be wrong.

The easiest way to check it is to run your task and see what nextrun says before it completes.
Quote:
Originally Posted by kh99 View Post
You're right that the time that the task runs won't be exact, especially if your forum isn't busy, since it only runs when users request a page (that is, if you're talking about vb "scheduled tasks" and not actual cron jobs). Anyway, maybe another idea would be to let the task run on some regular schedule but have your code check a db field to see if it should do anything.
Thanks for your reply guys. What I'm going to have to do is what nhawk suggested; I have the task (vb task yes) setup to run tonight at midnight. I'm going to add my code in there and use "nextrun" field value to see when it creates the event. I can only speculate but I think that it should use the new value; think about it, the task is already running so why would the nextrun time still be the same. I'm trying to narrow it down to the second so I know this can be difficult. I could have the code in the task check a db field but the only value that I know for a fact that I can use to setup an event on the same exact time as the next task/cron is in the field I mentioned. Anything else could be subject to other circumstances, using this field I eliminate any other variable that might have been overlooked. Or what I just thought about now, would be to set up somehow that my code to create the event runs (in a separate file) as soon as the cron is completed running, that way I know that the field has been updated already. In any case i'll let you guys know my results as soon as the task runs tonight, I'll post here for anyone to use a future reference of when this field is updated although if you have any more thoughts or ideas please do tell

--------------- Added [DATE]1313719820[/DATE] at [TIME]1313719820[/TIME] ---------------

OK guys got it working better than I had hoped

I used the previous code in my cron file and waited for the task to run. Had to make some posts throughout the night to make the forum "active" so the task would run and when it did at first with the code mentioned before :

PHP Code:
$aotw_next_time time() + 604800
This worked but the time it gave me was 13 second late This in turn created the event but 13 seconds past the time it needs to be; vb for some reason places single events in the calendar at 00:00:00 GMT, if you set the event 13 seconds late the event although recorded in the database does not appear in the calendar. Even if it's 13 secs past 00:00:00. Anywho I created a hybrid of our ideas, used this code but also a db recording I have of the time set as "start time" ,here's a snippet of the entire cron file.
PHP Code:
            //This will get the edition # of said contest//
            
$result0 $vbulletin->db->query_read("SELECT * FROM cotw_aotw_time_end ORDER BY id DESC LIMIT 1");
            
$row0 mysql_fetch_row($result0);
            
$edition $row0[0] - 1;
            
            
$next_edition $row0[0] + 1;
            
            
//This will get the next contest date for settting next event of said contest//
            
            
$result1 $vbulletin->db->query_read("SELECT aotw_unix_start FROM cotw_aotw_contest_start_unix");
            
$row1 mysql_fetch_row($result1);
            
            
$aotw_next_time $row1[0] + (604800 $edition); 
            
            
//Create Next Weeks Event/Contest//====================================================================================//
            //===================================//==========================================================================//
            
            
$vbulletin->db->query_write('INSERT INTO `event` (`eventid`, `userid`, `event`, `title`, `allowsmilies`, `recurring`, `recuroption`, `calendarid`, `customfields`, `visible`, `dateline`, `utc`, `dst`, `dateline_from`, `dateline_to`) VALUES (NULL, \'1\', \'Contest Type: '.$vbulletin->options['cotw_aotw_next_type'].'\', \'Avatar of the Week # '.$next_edition.'\', \'1\', \'0\', \'\', \'2\', \'a:0:{}\', \'1\', \'1313616397\', \'0.00\', \'0\', '.$aotw_next_time.', \'0\');');
            
            
//==============================================================================================================// 
This worked PERFECT, to the second! This way it also gives the user a chance to "deactivate" the contest and then restart it with a new date whenever.

There's some other aspects to work out but the initial issue of this thread is SOLVED my friends. Thanks for your help again, your help has been incredibly helpful for my learning process.
Reply With Quote
 


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

Forum Jump


All times are GMT. The time now is 12:41 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03706 seconds
  • Memory Usage 2,466KB
  • Queries Executed 12 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (4)bbcode_php
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)showthread_list
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_threadedmode.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids_threaded
  • showthread_threaded_construct_link
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete