![]() |
Something strange about cronjobs
After looking into some error reports on my Thread of the Week hack, i found the reason of the errors in some strange (in my eyes) behaviour of job run using the Scheduled Task Manager.
Test script 'includes/cron/test.php': PHP Code:
Now add a new Task with the Scheduled Task Manager, pointing to this file, set it to log the action. If you now press "Run Now" and look at the lines written into the Scheduled Task Log. It will look like this: Code:
134 test 18:34, 6th Feb 2005 In function test1 i set the vars $log and $count to global, thus giving me access to the same vars as used in the mainline. I again add a line to the $log and increase $counter. Now return to mainline. Back in the main line $counter still contain the value as set in the function, and $log now contain 2 lines. I add 1 more line, write $log to the Scheduled Task log and finish. This is exactly what happens when i run it with the "Run Now" button. Now i repeat the test, but this time i let it run automatic, by setting a time for the Task to run. I wait till it has run, and go look in the Scheduled Task Log. I expect exactly the same output, since it is the same script. But, output is as follows: Code:
138 test 18:44, 6th Feb 2005 What am i missing here? PS Yes when i also in the main line declare these 2 vars as global, or if i would pass them as parameters to the function, i could make this work. But that is not the point. I just want to understand what is going on. |
Hmm a tiny bump?
|
Nobody got an opinion about this??
PS Maybe if a Mod would move it to the "PHP / MySQL / JS / (X)HTML" section, although i think it more belongs here. Bee-Baa-Bumper |
Bumperty, Bumperty, Bump
Really nobody? |
hmm can you explain in 2 line what exsacly are you tring to do ?
|
Well put shortly: In the main line i define a variable $var, assign a value to it, i call a function. In that function i do a "global $var;", assign a new value to $var and return to main.
If i run this with "Run Now", all go like expected: $var gets assigned in main, after the "global $var" i can in the function access the value set in the mainline, and on return to mainline, i still have the new value set in the function. If run through the scheduler however, this will not pass the value of $var to the function or back to the mainline. PS Sorry 3 lines :D |
Time for a small bump i think
|
I too have found this to be the case. I am writing a scheduled task as we speak and it's just not running. Existing vB scheduled tasks run fine. Mine runs fine from the run now button, but it does absolutly nothing on schedule.
I read threads at vBulletin.com and it seems they are not giving anyone that points this out any more then the answer that it works. But it don't. |
Yes i know it doesn't work as you would expect. Took me a long time and the help of a frustrated user of my Thread of the Week hack to find out what was "wrong"
If you need help with your cronjob, let me know. Think i know now what to look for. |
Quote:
Actually, I got mine working after I posted. I don't give up easily! Thanks for your input though. My problem was exactly that, my problem. The thing works as intended. I'm not sure about all of it, but I got the job done. |
I not tried posting this on vb.com or as a bug yet, thought i could first get the opinion of some fellow coders on it.
But because of the lack of response in here, and teh confirmation from noppid that i am not alone on this, i think i will try it with a bug report and see what reaction i get. |
The scheduled task script in vB appears to be just for simple stuff and rarely seems to work correctly when incorporated into mods. I have the NNTP gateway script included on my site and it would only partially work (would recieve usenet posts fine but wouldn't send out any) so instead of using the scheduled task manager I just used real cronjobs. Now it works perfectly.
I don't know why this is the case, just letting you know other hack authors have had the same problem. |
Then i think it is about time we do something :D
|
Did you ever report this MarcoH64? .. I can't find the bug report if you did.
|
I think there was (in the vB3.0 bug reports)
|
Ahh .. didn't see the date of the thread .. I was looking in the 3.5 bugs ..
Reason I ask is that I'm seen a similar problem with a cron job for a hack, where it works fine if "run now" and yet when it runs at the time set it says its run correctly in the logs but it seems only some of the script runs .. You said above you know what to look for .. is it something obvious, or is it something deeper you need to add to the code? |
Are you using functions in your script that rely on global variables?
PS That bugreport was closed with a "Working as Designed" if i remember correct. |
Rehashing an old thread, I have the same exact problem and found that the global variables were the key. Is there a solution to this short of moving all my global variables into the individual processes ? (pain! :)
|
All times are GMT. The time now is 08:58 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 | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|