![]() |
vB3 cron system
What is the CLEAN (i.e., not exit!) way of ending a cron script?
For example, I have this function: PHP Code:
|
My host says return;
dunno if thats any help :p |
Quote:
I don't want to edit any of vB's files, if possible, as this is for vBMS and I'm avoiding that for this release. |
A thought occurs: is there an exit handler function that will make a graceful exit anyway when exit is used?
|
How do you mean? (me lost) my host still swears u should use exit at the end of the cron line
|
Quote:
|
Doh! :( Sorry for wasting your time Filburt.
|
Filburt isn't control given automatically given back to the main cron script as it loops through each required file? Unless your function isn't itself going to be a cron script.
Cheers, g-force2k2 |
Quote:
PHP Code:
|
Could not not define a global variable that is ran through each loop and if an error is occured then instead of continuing the while loop it could instead break out, and if necessary first build a new cron log? Just an idea.
Cheers, g-force2k2 |
The latest code block I posted is already at the global level. It would be easy for me to raise an error flag, but the problem is I would have to have a gargantuan tree of nested ifs (at least ten, more likely around 20) in order to gracefully have the code flow to the end of the file (the point at which the cron system resumes its work with the next job).
|
so then are you trying to break the control of the cron job to stop the following scheduled cron jobs, because I see that you are logging the error that has occurred, and if thats the case couldn't you simple add a continue ; to end that section of the while loop in the file, after it the included cron php files are within the actual loop, it would then resume the next cron job after all, because the continue only breaks that certain loop.
Cheers, g-force2k2 |
To clear the ambiguity, I'm trying to make my custom cron job (vbms_checkmail.php) gracefully terminate and yield control to the next scheduled job (whatever.php), if there is any.
|
Alright, then couldn't continue ; possibly do the trick?
Cheers, g-force2k2 |
That's actually a really good idea. The only problem would be that it could reference the wrong loop (for example, if I want to exit from within a loop).
Or wait, how would it work exactly? If continue is used in a function where there aren't even loops, would PHP just reversely traverse the code tree until it finds a loop, and then force the next iteration? edit: http://www.php.net/continue for reference doesn't mention anything other than the freaky fact it supports an argument. I wish PHP was as clean as Java but as easy as it is now... |
Hmm... very interesting, I did some tests with continue ; in both an included file and a function and both returned errors, but something else did work.
PHP Code:
numbermain.php PHP Code:
PHP Code:
PHP Code:
Code:
1 Cheers, g-force2k2 |
Well remember that because PHP's file inclusion functions are essentially identical to the #include preprocessor directive in C--just dumps a file into another file--the code being run is this:
PHP Code:
|
Quote:
Cheers, g-force2k2 |
Quote:
Quote:
|
Interestingly, it looks like exit; will work. vB registers a shutdown function via register_shutdown_function() named exec_cron() that will, hopefully, cause the cron jobs to continue to run.
|
Well it just kills the script instead. I would very much appreciate a developer's input.
My exit function: PHP Code:
|
This is now effectively the last major outstanding issue in releasing an alpha for vBMS. I would very much appreciate some more help (and thanks to those who have helped so far).
|
All times are GMT. The time now is 10:19 AM. |
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:
|