+ Reply to Thread
Results 1 to 5 of 5

Thread: Setting up a Cron Job

  1. #1
    Join Date
    Feb 2008
    Location
    Rio Rancho, NM
    Posts
    53

    Default Setting up a Cron Job

    I want to set up a Cron Job for a Wordpress site using the Postie plugin. The plugin requires this code to be ran:

    */5 * * * * /usr/bin/lynx --source http://www.economysizegeek.com/wp-co...e/get_mail.php >/dev/null 2>&1

    I really don't know what to do with it. I found the Cron Jobs section in the Cpanel but I'm just confused. I've never done this before. I would like to run this about once an hour or two.

  2. #2
    Join Date
    Jan 2008
    Posts
    100

    Default

    Quick cron tutorial:
    The first numbers/wildcards refer to the following:
    1 - minute
    2 - hour
    3 - day (of month)
    4 - month
    5 - day (of week)

    That means that:
    */5 * * * *
    will run every 5 minutes on every hour of every day of the month on every month on every day of the week.

    To change this to run hourly, you can do something like this:
    0 * * * *
    This will run every 0th minute (i.e. o'clocks, 1:00, 2:00, ...) of every hour on every day....

    or something like this:
    5 * * * *
    will run at 1:05, 2:05, ....

    Next is the command:
    /usr/bin/lynx --source http://www.economysizegeek.com/wp-content/plugins/postie/get_mail.php >/dev/null 2>&1
    Eh, it's ok I guess, but typically, people use wget for this task. This command is what cron runs. There are three default file descriptors:
    0 = stdin - used for input
    1 = stdout - used for output
    2 = stderr - used for errors
    The "greater than" symbol redirects output from one of these file descriptors. This command is telling lynx to download the aforementioned page, then redirect its output to the following:
    >/dev/null 2>&1
    By default, if no number is mentioned, it's "1", or standard out. That means that this can be written equivalently (for easier understanding) as:
    1>/dev/null 2>&1
    This directs the page that's downloaded to output its source to the null device (i.e., it throws it away). If there are any errors, it sends it redirects them to stdout, which is then redirected again to /dev/null (i.e., throw them away).

    Search for the lynx and wget manuals to understand how those commands work.

    When you click on "cron jobs" in cpanel, click on "go advanced" to insert the data there. Alternatively, feel free to use the simpler interface if you're not comfortable using the above directions.

    Good luck!
    Last edited by squinky86; 01-20-2009 at 06:07 PM. Reason: stupid automatic links....

  3. #3
    Join Date
    Feb 2008
    Location
    Rio Rancho, NM
    Posts
    53

    Default

    Thanks for your handy tutorial! I tried it out in Cpanel but now how do I know if it works? I don't see an option that shows the Cron job that I just submitted. Is there a way to find it?

  4. #4
    Join Date
    Jan 2008
    Posts
    100

    Default

    Quote Originally Posted by turtlepirate View Post
    Thanks for your handy tutorial! I tried it out in Cpanel but now how do I know if it works? I don't see an option that shows the Cron job that I just submitted. Is there a way to find it?
    If it's not showing up after adding it, you need to submit a support ticket. After you click on "standard" or "advanced," you should see your new cron job as one of the entries.

  5. #5
    Join Date
    Feb 2008
    Location
    Rio Rancho, NM
    Posts
    53

    Default

    Thanks again, I must have done it wrong the first time but the second time it showed up. I think I'm all set now.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts