WordPress.org

Ready to get started?Download WordPress

Forums

Post Expirator
[resolved] Cron runs every 60 seconds! (25 posts)

  1. brianoz
    Member
    Posted 2 years ago #

    Love Post Expirator!

    The cron job runs too often though, likely to be a resource hog or problem with some hosts (we're a host ourselves).

    Can it be reduced to hourly? We don't usually need posts expired every minute!

    :)

    http://wordpress.org/extend/plugins/post-expirator/

  2. wroc54
    Member
    Posted 2 years ago #

    in post-expirator.php
    'interval' => 60,
    convert to
    'interval' => 3600,

  3. brianoz
    Member
    Posted 2 years ago #

    Ummm ... you can't be serious about that? What happens on the next update?

  4. Aaron Axelsen
    Member
    Plugin Author

    Posted 2 years ago #

    The plugin by design is set to run every minute. Now, are you looking to run this on a multisite network or just single hosts? Because I could look into adding an option to select, but that wouldn't address your concern if users can select this themselves.

  5. brianoz
    Member
    Posted 2 years ago #

    Thanks for the thoughtful response Axel.

    The issue is that I believe running every minute, just in case you need to do something, is over using resources. If you literally had an event every minute, no problem, but 99.99999% of the time you will simply be running a query and exiting.

    What would address the issue nicely would be this: by default, for the plugin to run hourly. Then, as well, there's an option somewhere that says, "Use precise timing" (or better wording, that's my poor wording) and ran every minute. I'd suspect this would be more than acceptable for most people, who really don't care when a post is expire down to the minute -- eg for me, so long as it's within an hour or so, no problem.

    For those few who did care about the timing down to the minute, they could select the option and deal with the extra overhead.

    BTW, to check whether a cron entry exists you might be able to use wp_next_scheduled() - that could be run every hour to see whether expirationdate_delete is still scheduled, and if not, to replace. You then wouldn't need the manual Reset button except in dire circumstances. :)

  6. Aaron Axelsen
    Member
    Plugin Author

    Posted 2 years ago #

    This plugin originally was only available to run every hour. There was actually a huge demand for it to expire on the minute, which is one of the reasons why it was changed. I would likely keep "minute" as the default, and look at having an option to use hourly.

    This will required a good amount of changes/testing, so it will be a bit before it's ready. If you are willing, once I get it in a "beta" worthy state, I can shoot a link over for testing.

    I always have resources usage in my mind, and do what i can to minimize unnecessary db calls, etc.

    I'll probably re-work the cron entry check, and keep it as an admin side only checked. Because if something is screwed up with the cron scheduled, its likely any additional events to check the schedule would also be hosed.

  7. brianoz
    Member
    Posted 2 years ago #

    Sure, happy to help if I can, and thanks for being willing to look at it and discuss it.

    Obviously the other option is to schedule the events for exactly when the expirations are needed, with an hourly event to just check everything is OK.

    That way you get control down to the minute, without using any resources at all.

    I take your point about keeping the cron check button in admin. It wouldn't be unreasonable to just check that the hourly cron event is scheduled on all admin pages, then the hourly event can do more extensive checking and you don't need to get people to click on a reset button. Although, you may like the button! :)

    Thanks again, BTW, looks like you are king of the download stats, you have some serious download numbers happening!

  8. Aaron Axelsen
    Member
    Plugin Author

    Posted 2 years ago #

    I have implemented some tweaks in the dev version - take a look and let me know if it works and does the trick for you.

    http://downloads.wordpress.org/plugin/post-expirator.zip

  9. brianoz
    Member
    Posted 1 year ago #

    Sorry to be so very slow to respond to this.

    I had a look at the code, but without diffs or some idea what you'd done it was hard to follow.

    What needs to be done is to schedule the cron jobs at the time the next post needs to change. That way you get as near exact granularity as you can while not wasting CPU cycles (and getting blogs running your plugin into trouble with hosts like myself! :)). More seriously, many hosts these days measure excess CPU users and kick blogs off if they are violators.

    If you like, you could schedule an hourly check for cron being set correctly, it's only when stuff polls every minute that you'll run into trouble.

  10. ip00
    Member
    Posted 1 year ago #

    We have been using Post expirator on one of our sites for over two years. We only had one issue after one of the upgrades, but this site always used a bit more resources than others with similar visitor count.
    I was keen to put the blame on the code we wrote (theme and custom made plugins) but I was wrong. I have checked with our hosting company and they said load is caused by something in wp-cron.php. Other than usual WP stuff Post Expirator was the only plugin using scheduler. We have rescheduled it to run hourly and loads fell into normal.

    So I second what brianoz wrote about scheduling cron jobs at the time the next post needs to change. No one wants to waste resources.

  11. Aaron Axelsen
    Member
    Plugin Author

    Posted 1 year ago #

    Just to let everyone know, I am adjusting the plugin to schedule an event for each post - because that is a much better way to go about this. When the plugin first came about I believe there was some limitations with that route.

    Either way, I hope to have something ready for "testing" in the next week or so (pending all goes well). Any volunteers to test it out?

  12. ip00
    Member
    Posted 1 year ago #

    Good news. Post a notification here when it is ready for test.

  13. Aaron Axelsen
    Member
    Plugin Author

    Posted 1 year ago #

    Just doing some cleanup and I'll have to spend a couple days testing the upgrade path before releasing it to you guys to try out. Here is a sneak peak to date of whats changed:

    * New: Improved debug calls and logging
    * New: Added the ability to expire to a "private" post
    * New: Added the ability to expire by adding or removing categories. The old way of doing things is now known as replacing categories
    * New: Revamped the expiration process - the plugin no longer runs on an minute, hourly, or other schedule. Each expiration event schedules a unique event to run, conserving system resources and making things more efficient
    * New: The type of expiration event can be selected for each post, directly from the post editing screen
    * New: Ability to set defaults for each post type (including custom posts)
    * Fix: Removed kses filter calls when then schedule task runs that was causing code entered as unfiltered_html to be removed
    * Fix: Updated some calls of date to now use date_i18n
    * Fix: Most (if not all) php error/warnings should be addressed
    * Fix: Updated wpdb calls in the debug class to use wpdb_prepare correctly

  14. Aaron Axelsen
    Member
    Plugin Author

    Posted 1 year ago #

    For those of you who were interested in testing - please grab the version from the SVN trunk. http://downloads.wordpress.org/plugin/post-expirator.zip

    I want to roll this out within the next few days. I have tested every upgrade scenario and post scenario that I can think of - so additional testers are welcome.

    The only outstanding issue that I am still working on is:

    - when checking default post categories, the categories of the epxiration box are also checked.

    The changes included are:

    * New: Improved debug calls and logging
    * New: Added the ability to expire to a "private" post
    * New: Added the ability to expire by adding or removing categories. The old way of doing things is now known as replacing categories
    * New: Revamped the expiration process - the plugin no longer runs on an minute, hourly, or other schedule. Each expiration event schedules a unique event to run, conserving system resources
    and making things more efficient
    * New: The type of expiration event can be selected for each post, directly from the post editing screen
    * New: Ability to set defaults for each post type (including custom posts)
    * New: Renamed expiration-date meta value to _expiration-date
    * New: Revamped timezone handling to be more correct with WordPress standards and fix conflicts with other plugins
    * Fix: Removed kses filter calls when then schedule task runs that was causing code entered as unfiltered_html to be removed
    * Fix: Updated some calls of date to now use date_i18n
    * Fix: Most (if not all) php error/warnings should be addressed
    * Fix: Updated wpdb calls in the debug class to use wpdb_prepare correctly

  15. sergeytru
    Member
    Posted 1 year ago #

    * New: Revamped the expiration process - the plugin no longer runs on an minute, hourly, or other schedule. Each expiration event schedules a unique event to run, conserving system resources
    and making things more efficient

    - How this approach will work for currently expired posts?

  16. Aaron Axelsen
    Member
    Plugin Author

    Posted 1 year ago #

    it has no impact on currently expired posts (other than renaming the meta value) - since they are already expired, and nothing had to be changed.

    Any posts that are scheduled to expire in the future will have an event schedule for them at upgrade time.

  17. brianoz
    Member
    Posted 1 year ago #

    Aaron,

    Haven't had time to follow this in detail, but it sounds like a nice piece of work! Thanks for following through on this, I'm sure many users (and hosts!) will enjoy the results!

    :)

  18. sergeytru
    Member
    Posted 1 year ago #

    What means Default Date/Time Duration = Post/Page Publish Time?
    Does it mean the post will be expired just after it's published?
    In this case what the sense of the setting?
    If it so - for me it's useful the only with additional parameter Relative post expiration time, say default: 30 days from published.

  19. Aaron Axelsen
    Member
    Plugin Author

    Posted 1 year ago #

    @sergeytru This is not a new feature - it does set the expiration date/time to be the same as the post time. What your describing is not currently part of the plugin

    @brainoz thanks - it was due for an overhaul!

  20. sergeytru
    Member
    Posted 1 year ago #

    Aaron,

    Any posts that are scheduled to expire in the future will have an event schedule for them at upgrade time.

    - this situation may be anytime when server is too busy, or scheduled event in server maintenance time. It will be useful to check expired posts to enforce their expiration..

  21. Aaron Axelsen
    Member
    Plugin Author

    Posted 1 year ago #

    There is really no clean way to do that. If the past posts are not expirated correctly, I think they will need to be manually taken care of. There is no way to know how an old post was suppose to be expirated - whether to delete or draft - and we can't make the assumption to use what the default is currently configured as.

  22. sergeytru
    Member
    Posted 1 year ago #

    Aaron, I know the Post/Page Publish Time is old, but just can't understand how it's useful. I'm newbie with your plugin - just installed it, it does not work for me, and I'm looking for same issue on the forum.

  23. ericekidwell
    Member
    Posted 1 year ago #

    Hi Aaron,

    I downloaded and installed the plugin, but it's still not working for me.

    Any news on an update?

  24. Aaron Axelsen
    Member
    Plugin Author

    Posted 1 year ago #

    @ericekidwell what version of the plugin are you running? What does the debug log tell you? Can you define "not working" in more detail?

  25. freemanhelp
    Member
    Posted 1 year ago #

    Aaron,

    Great plugin! When new posts are published, I am having to manually Update the post for the expiration date to activate. All my settings appear correctly set. Am I missing something? I thought it was supposed to happen automatically. Any guidance would be much appreciated.

    In addition, upon manual Update, the expiration date appears to be triggered by the_modified_time() as opposed to the_time(). I think I may have a bug in my system, but I thought I would reach out to you before I dig too deep.

    Thanks again for the great plugin.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags