• Resolved Paul

    (@yearn2earncashdotcom)


    I have an issue with scheduling automatic online backups that has been bothering me for quite some time. It is absolutely nothing wrong with the actual plugin itself. It is an issue with my WordPress scheduler.

    I know that because even my scheduled posts fail all the time unless I use another plugin to fix the issue.

    I use the WP Missed Schedule plugin to ensure that my scheduled posts always actually do get posted at my specified times.
    The plugin author has made an excellent plugin there for people like me with some sort of WordPress scheduling issue that cannot be determined. It apparently runs via a Cron Job.

    My question is can you create a simple “Sheduled Backups Cron Job” plugin that would enable the backup plugin to run the scheduled backups at the time we specify?

    I think if it was possible to create something like this then there would probably be quite a few less support questions for scheduler issues as many people seem to have some indeterminable WordPress scheduling problem.

    https://www.ads-software.com/extend/plugins/wponlinebackup/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Online Backup

    (@driskell)

    Hi,

    As long as your server is configured correctly and you are getting a steady stream of visits from users and web crawlers etc everything should run very well.

    WordPress scheduler automatically runs every time something visits the blog, but no more than once a minute. When it detects jobs need running it will attempt to “visit itself”, then deal with the actual visit, so the “visit itself” does the work, while the current visit can be dealt with immediately and without delay. WP_ALTERNATE_CRON in wp-config will do it slightly differently and works for some people. When it detects jobs need running it will redirect the visitor so they can be dealt with immediately, and then deal with the work. So, both ways make sure the visitor gets a quick page load, and that jobs still get run.

    These are the two different approaches by WordPress. The first one the default and working the best for most people.

    However, the problem comes if your blog is https://www.blog.com, but the server hosting it doesn’t know where that is (an example of poor configuration by a web host… sometimes it is referred to as “server doesn’t allow loopbacks”.) WordPress tries to “visit itself” on default configuration and finds that when it tries to access https://www.blog.com… it gets back a failure. Thus the scheduled jobs do not run. It is this instance where WP_ALTERNATE_CRON is provided as a workaround.

    Another issue you might have is the schedules run but they run far too late (since they require a visitor and maybe you aren’t getting many visitors). WordPress consider this acceptable since if there are no visitors, visitors don’t notice a problem!
    One way to fix this is to use Cron Job on your server, but this still requires that your server can find your blog, https://www.blog.com for example. You’d enable DISABLE_WP_CRON in wp-config so it knows not to do schedules when visitors visit, and you’d create a cron job to run every 5 minutes or so and make the command something like “wget -q -O – https://www.blog.com/wp-cron.php?doing_wp_cron &>/dev/null”.

    The plugin you mention only fixes missed scheduled posts and I believe is only needed in the situations where WP_ALTERNATE_CRON would be intended to be used. The plugin likely publishes the posts when a visitor visits but does it before the visitor is dealt with. So it will delay the visitor’s page load slightly, but since publishing a scheduled post is simple it likely is insignificant. However, doing the backup is not simple and much heavier work so it would not be feasible at all to have a similiar plugin.

    Usually, things just work. If not, WP_ALTERNATE_CRON is the best second approach.
    If schedules run sporadically and too late, the site is low visitors, so don’t use WP_ALTERNATE_CRON and setup Cron Job instead. But once web crawlers start indexing this normally fixes itself.

    I hope you don’t think TLDR ?? But I figure it would be good to document all this here for all to see if anyone else has similar issues again. Google searching WP_ALTERNATE_CRON etc will bring up some good guides.

    Regards,

    Jason

    Thread Starter Paul

    (@yearn2earncashdotcom)

    Hi Jason.
    Thanks for that explanation, it really did provide some interesting reading, and yes I did read it.
    (Although I had to Google TLDR to find out it meant too long, didn’t read!)
    I will read up on some the guides you mentioned as I think it might be something I will need to do, as even though I do get traffic to the blog throughout the month, the scheduled backup always has a status reading of “Due to start any minute” and never actually does start (even if months go by).
    I also think others will benefit from seeing this detailed post, and I am glad you provided such detail.
    Regards,
    Paul.

    Plugin Author Online Backup

    (@driskell)

    You’re welcome Paul!

    I think you’ll find the WP_ALTERNATE_CRON option in WordPress very useful though and should fix your issue. Just add inside your wp-config.php:

    define(‘ALTERNATE_WP_CRON’, true);

    Jason.

    Thread Starter Paul

    (@yearn2earncashdotcom)

    Ha! Well I’ll be damned! You fixed it Jason!

    I never thought it would be that easy to fix this longstanding problem with my WordPress, so I was preparing to study several different “WP_ALTERNATE_CRON” articles that looked very complicated, but as an afterthought I did add define (‘ALTERNATE_WP_CRON’, true); to my wp-config.php file as you suggested.

    I set a time to run the scheduled backup and carried on looking around some other sites and forgot about it. When I returned to my blog to check on it I noticed the following code appended to the end of all my URL’s:

    ?doing_wp_cron=1363271049.9576210975646972656250

    I thought this must be another error, but when I checked on the online backup I could see that “A backup is currently running”

    The only thing I had to do was go to my online backup settings and logout and then login again as you had suggested in some other support threads, and it resulted in this working perfectly. Everything is great again now and my automatic backups are transmitted to the server just as they were a very long time ago.

    I think a lot of others will benefit from reading your post.
    This is one thread that’s well and truly resolved!

    Thank you!

    Regards,
    Paul.

    Hi Jason!
    Well your solution is pefect! My sole problem with your plugin is now fixed, thanks for your help!
    Best Regards,
    Mubbashir

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Sheduled Backups Cron Job’ is closed to new replies.