1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

perl cron?

Discussion in 'PHP & Perl' started by essares1, Dec 18, 2010.

  1. essares1

    essares1 Junior Member

    Joined:
    Apr 27, 2009
    Messages:
    163
    Likes Received:
    27
    Does anyone know how to setup perl cron in Hostgator. I have tried this

    Code:
    /usr/local/bin/perl /home/USER/public_html/PATH/cgi-bin/script.pl
    but its not working. I changed several things but nothing seems to work. Anyone?
     
    Last edited: Dec 18, 2010
  2. MaDeuce

    MaDeuce Newbie

    Joined:
    Oct 24, 2008
    Messages:
    45
    Likes Received:
    16
    Location:
    Austin, TX
    Dunno about hostgator, but here are some generic things to look at:

    1) Running as a user or as root?
    2) cron.allow / cron.deny provisioned correctly?
    3) What does your entire crontab entry look like?
    4) What output are you getting from cron when the job runs? Check the owner's email...
    5) Can you get a basic job to run? E.g., can you setup a 'echo "hello,world"' to run once a minute? No point in trying to do anything more complicated, if this base case is causing problems.
    6) Obvious, I know, but is your path to perl correct?
    7) Your command line looks correct but, what happens if you add
    Code:
    #!/usr/local/bin/perl 
    to the first line of script.pl and
    Code:
    'chmod +x ./script.pl'
    ?

    My guess would be that you are having problems at #5 above. Once you get that fixed, you ought to be able to do what you want pretty easily.

    --Ma
     
    • Thanks Thanks x 1
  3. essares1

    essares1 Junior Member

    Joined:
    Apr 27, 2009
    Messages:
    163
    Likes Received:
    27
    Yea I am trying to run a simple test script. The paths are all correct cause I could run the same thing from putty ssh. perl path is also correct. I can run the perl script and get output on my web browser too. the cronjob is not running at all. so no output to email.

    What is cron.allow and deny? should I change it or something?
     
  4. fatboy

    fatboy Elite Member

    Joined:
    Aug 13, 2008
    Messages:
    1,618
    Likes Received:
    3,227
    Occupation:
    Retired
    Location:
    Old Peoples Home
    Edit your cron job and try something like:

    Code:
    cd /home/USER/public_html/PATH/cgi-bin/ && ./script.pl
    
    You will have to +x the script as MaDeuce said.
     
  5. Albertux

    Albertux Newbie

    Joined:
    Nov 28, 2010
    Messages:
    11
    Likes Received:
    1
    you need to put the time for a cron, in this example every 5 minutes execute the test.pl script (chmod +x test.pl)
    Code:
    */5 * * * *  /home/user/test.pl
     
  6. headliner

    headliner Registered Member

    Joined:
    Oct 2, 2009
    Messages:
    51
    Likes Received:
    5
    If you are able to... check out your cron logs as well to see if there is a failure. You may have a failure reason in the logs.