The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
Cron Job Broken
I've written a custom cron job to interact with a mod I am working on. However the cron job doesn't work every time. If I run it manually it works without any problem, however it doesn't seem to run automatically despite the scheduled task manager showing it ran.
Is there some kind of error in my coding that would cause this? I'm reluctant to post the code but will if needed. |
#2
|
||||
|
||||
I've written cron jobs before that only run manually because I didn't have the code correct. Find a similar one that vbulletin wrote and compare it to yours and see if there are things missing (I seem to recall I forgot to make something global in mine).
|
#3
|
||||
|
||||
Some variables do not exist when scheduled tasks are not run from the Admin CP. Also, keep in mind that the task has a possibility of running as a guest.
|
#4
|
||||
|
||||
Thank you for both of your responses. I've PMed you the code if you have the chance to review it that would be swell.
Lynne, I've globalized only $vbulletin and a few vars I want to hold the string outside of functions. I'm unsure what else would need to be done. Dismounted, How would this make a difference? I'm stating that the task works when run manually by clicking on "Run Now" not from outside the Admin CP. I don't think you can even run it stand alone as it calls the db defined by vbulletin. There isn't any code in it that would matter as for member vs guest. --------------- Added [DATE]1242226401[/DATE] at [TIME]1242226401[/TIME] --------------- After getting a response from Lynne I've decided to post the code. Anyone who see's an issue please help! For reference I am not currently giving permission to reuse the code. PHP Code:
|
#5
|
||||
|
||||
Do you see anything in your error_logs? And is any of that script getting done? Is see you have some update queries and I'm just wondering if some are happening before the script stops.
|
#6
|
||||
|
||||
I have nothing in my error logs.
This query appears to always take place: $vbulletin->db->query("UPDATE xblusers SET time='$checktime', date='$checkdate' WHERE title='checked'"); And this one takes place when the if statement is true $vbulletin->db->query("UPDATE xblusers SET time='$checktime', date='$checkdate' WHERE title='crashed'"); It appears the code inside my while is where the issue lays as when the cron job automatically runs the insert queries do not take place. Also my log_cron_action doesn't log ethier when run automatically or manually. I haven't checked if the userfields update query is saving. I will keep an eye on that now. |
#7
|
||||
|
||||
Well, if I were to debug this, I'd do things like take out functions and such to see if they are the problem. For instance, change this line to simple give the results (true or false) and see if the job continues to run:
PHP Code:
|
#8
|
||||
|
||||
Will do.
I also updated my Insert, Update statement to query_write function. Not sure if that matters. The userfield queries where not taking place either. --------------- Added [DATE]1242234837[/DATE] at [TIME]1242234837[/TIME] --------------- Well that was easier than I was making it. It appears it is the function. Strange the function works flawless when I run it manually but not when it's automatic. Thanks Lynne, anyone who can offer a reason as to why function doesn't work I'd appreciate it. |
#9
|
||||
|
||||
I had problems with using a function in my cron job, too. You need to pass any variables it is going to need and you need to globalize everything also. And, any functions you want it to use, you need to make sure to include them in the functions. You have to treat the function like it lives in it's own little world and knows nothing of the outside world except what you pass it.
|
#10
|
||||
|
||||
Will do,
Thanks again Lynne +Rep if I could |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|