How do I set up a cron job to check my feeds for updates

Contents

[ hide ]

    For more how-tos and advice, return to How Do I …?

    Q. How do I set up a cron job to check my feeds for updates?

    A: First, let’s talk about what you need to put in your crontab file. If you don’t know what a crontab is, or don’t know how to edit yours, I’ll talk about that below. If you do know what a crontab is, and know how to edit or add jobs to yours, the main thing you need to know is that you can perform scheduled updates by sending regularly-scheduled HTTP requests to your blog’s URL with a GET parameter set to update_feedwordpress=1. So, for example, if your blog is at http://example.com/, then inserting the following line in your crontab:

     */10 * * * * /usr/bin/curl --silent http://example.com/?update_feedwordpress=1
    

    will check in every 10 minutes and check for updates on any feeds that have been marked as ready for polling. (Note that this does not mean that all your feeds, or any of your feeds, will be polled for updates once every 10 minutes. What happens once every 10 minutes is that FeedWordPress will check whether any feeds are ready for polling, and if so poll them. Feeds typically get marked as being ready to check again about 60 minutes after the last time that they were checked for updates.)

    How to edit your crontab

    A crontab is a plain text file used by the Linux/Unix cron service to run commands according to a fixed schedule. (Since cron is designed for tasks that need to be executed repeatedly at a certain time or date, it is typically used to schedule regular maintenance tasks. In this case, we want to use it to schedule the task of telling FeedWordPress to check for feeds that need to be polled for updates.)

    Every crontab contains a series of lines, with each line representing a cron job — which means a schedule (expressed as a series of numbers), and a command line to execute according to that schedule. The line you see above tells your web server to execute the command /usr/bin/curl with the arguments --silent http://example.com/?update_feedwordpress=1 once every 10 minutes.

    The best way to edit your crontab depends on the resources that your web host provides. If your web host provides shell access, you can log into your shell account using ssh and just issue the following command at the command prompt:

     $ crontab -e
    

    If your host does not provide shell access, then your host is a bad web host. But oh well; sometimes you have to deal with bad web hosts. Some web hosts try to make up for not offering shell access by providing administrative interfaces on the web, such as cPanel or custom web-based Control Panels. If your web host offers cPanel, you can use this tutorial on creating cron jobs in cPanel. If you’re using DreamHost, they have a Wiki page with a lot of information on setting up cron jobs from their administrative tools. If you’re unsure, the best thing for you to do is to contact your web hosting company’s technical support, and ask them how to set up a cron job to run maintenance tasks for your website.

    Does that answer your question? If not, use the Talk page to comment on this post or contact me by e-mail for help. Be sure to describe what you are trying to do, and the problems you are running into, with as much detail as possible.

    For more how-tos and advice, return to How Do I …?

    This page is a Wiki! Log in or register an account to edit.

    14 thoughts on “How do I set up a cron job to check my feeds for updates

    Leave a Reply

    Your email address will not be published. Required fields are marked *