Cron Job Test

Discussion in 'Installation' started by dferrara, Jul 9, 2007.

  1. dferrara

    dferrara New Member

    Joined:
    Jun 10, 2007
    Messages:
    1
    How do I know if my cron job is working? Is there a way to test?

    Thanks,
    Dominic
  2. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    It's working if you don't see red alert in your aMember CP.
  3. dan_kelly

    dan_kelly New Member

    Joined:
    Aug 29, 2006
    Messages:
    91
    ... but this could take up to 24hrs to see the red alert.

    If it goes away right after to THINK you installed the CRON properly, don't get too excited. :) It could (and has for me) come back the next day.

    So, is there any way to KNOW that it is setup properly, without waiting an entire day?

    To OUR Success,
    Dan Kelly

    EDIT:

    I figured it out... it was a pain in the you know what, but...

    1. I created a few files for each of the methods available to call the CRON just. Each file simply used PHP to create a new file - with a unique name per command.

    Examples:

    "wget-hello-world-2.php" created a file called "wget-hello-world-2.txt"

    "lynx-hello-world-3.php" created a file called "lynx-hello-world-3.txt"

    That way, I know exactly which cron worked.

    2. I uploaded all the PHP files.

    3. I setup the cron file. Each line had a slightly different CRON command/path/etc... (The ones in the manual did not work exactly as is.)

    4. I sent the commands to run every hour at a certain minute - a minute that was 3 minutes into the future.

    Example:

    Current time is 4:28pm
    I set the job to run ever hour at 33 minutes: 33 0 0 0 0 CRON_COMMAND_GOES_HERE

    5. Wait 5 or 6 minutes and the check my server for the TXT files.

    6. Whichever text files exits, THAT'S your winning CRON command.

    Ta da!!

    7. Use the same command, with the amember/cron.php path info.

    For me, on 1and1 hosting, the command that worked was:

    11 1 * * * /usr/bin/wget -a wget.log -O- http://www.MY_DOMAIN.com/amember/cron.php

    This runs every DAY at 1:11am and saves a simple logfile to "wget.log" in my root directory. (The instructions in the manual has it running every HOUR on the hour, but this is a waste of system resources... since it only needs to be run once per DAY.)

    In case your curious...

    lynx did not work on 1and1.

    i think curl worked.

    11 1 * * * /usr/bin/curl -s http://www.MY_DOMAIN.com/amember/cron.php

    and, php worked.. this one is not document in the manual, but it ran the file OK.

    11 1 * * * /usr/local/bin/php /homepages/XX/dXXXXXXXXX/htdocs/MY_HTML_DIRECTORY/amember/cron.php > /dev/null

    dK

Share This Page