Find the answer to your Linux question:
Results 1 to 8 of 8
I have a cron job set up to run every two minutes but for reasons unkown its not running. It's a perl script and I know it's not erroring out ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Feb 2003
    Posts
    22

    Cron job every two minutes


    I have a cron job set up to run every two minutes but for reasons unkown its not running. It's a perl script and I know it's not erroring out for when I run it manually it runs fine. Here is what my crontab entry looks like

    */2 * * * * /usr/bin/perl /usr/local/sbin/script.pl

    Is there anywhere I can check in the logs to see where the error is.

    Thanks.

    Mike

  2. #2
    Linux Guru anomie's Avatar
    Join Date
    Mar 2005
    Location
    Texas
    Posts
    1,692
    Did you install this crontab? Which user did you install it as?

    Another thing: I could be wrong, but
    Code:
    /usr/bin/perl /usr/local/sbin/script.pl
    might be messing up cron (which is space-delimited).

    Maybe just for grins a couple ideas:
    1) put single quotes around it like:
    Code:
    '/usr/bin/perl /usr/local/sbin/script.pl'
    2) create a shell script that issues that command and call that shell script in your crontab.

    It's possible I don't know what I'm talking about. But I think one of these options should work.

  3. #3
    Just Joined!
    Join Date
    Feb 2003
    Posts
    22
    I installed it via 'crontab -e' as root. I tried calling it through a shell script doesn't work either. Strange.

  4. #4
    Linux Guru anomie's Avatar
    Join Date
    Mar 2005
    Location
    Texas
    Posts
    1,692
    Out of curiosity, what distro is this?

    I tried calling it through a shell script doesn't work either.
    That shell script may need to be executable.
    Code:
    chmod u+x script_name
    And finally (I keep thinking of things to check), confirm cron is running:
    Code:
    ps ax | grep 'cron'
    P.S. This is a long shot, but do you have existing /etc/cron/allow or /etc/cron/deny files? (Don't create them if you don't - won't help this situation.)

    edit: Combined multiple posts into one.

  5. #5
    Just Joined!
    Join Date
    Feb 2006
    Location
    Canada
    Posts
    7
    If the script contains the path to perl as it's first line, you don't need the path in the cron entry.

    As anomie said, make sure cron is running and the script is executable. Also, is the cron job and the script the same user?

  6. #6
    Just Joined!
    Join Date
    Feb 2003
    Posts
    22
    Yes, both the script and cron are run as root. The script itself is executable. I have checked that cron is running because other cron jobs are running so it must be a combination of some weird occurrences. Also this is on a debian box

  7. #7
    Just Joined!
    Join Date
    Feb 2006
    Location
    Canada
    Posts
    7
    Try making your cron entry as
    */2 * * * * perl /usr/local/sbin/script.pl

  8. #8
    Just Joined!
    Join Date
    Apr 2006
    Posts
    1
    I would suggest sending output to a file:
    */2 * * * * /usr/bin/perl /usr/local/sbin/script.pl >output.txt 2>&1

    This should capture error messages.
    In the past I have had crons that ran perfectly well at the command line, but failed as a cron. It was usually something in my code, and sending output to a file often helped debugging.

    Jason

Posting Permissions

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