How to run Perl script using Cron?

Discussion in 'Programming' started by tdoggy, Dec 13, 2007.

  1. #1
    I'm trying to run a .pl script at a certain time each day, using cron in cpanel, but it doesn't seem to work. I know the script works, because I can use Putty/SSH and run it using the command "perl myscript.pl"

    The command I used in the Cron looks like this...
    /usr/bin/perl /home/username/public_html/directoryname/myscript.pl

    Any ideas? :)
     
    tdoggy, Dec 13, 2007 IP
  2. NetStar

    NetStar Notable Member

    Messages:
    2,471
    Likes Received:
    541
    Best Answers:
    21
    Trophy Points:
    245
    #2
    Assuming you have all the right parameters like 00 00 * * *

    try:

    perl /home/username/public_html/directoryname/myscript.pl

    ALSO remember to use FULL paths to libs, files, etc. with in your script.
     
    NetStar, Dec 13, 2007 IP
    tdoggy likes this.
  3. chrisranjana.com

    chrisranjana.com Active Member

    Messages:
    132
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    58
    #3
    and if your host for some reason does not allow running command line scripts then you need to use either lynx or GET or any other command line browser tool to run the script assuming that it is a web based perl script.
     
    chrisranjana.com, Dec 13, 2007 IP
    tdoggy likes this.
  4. tdoggy

    tdoggy Well-Known Member

    Messages:
    375
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    108
    #4

    Thanks for your help. That is the command that I tried initially, and it didn't work. But I wasn't using full paths in the script. I just tried it using a simpler script and it worked. So now I just have to edit my script for full paths.

    Thanks again. :)



    Thanks, but I have no idea how to do that. Hopefully I won't have to ask you to elaborate, as things seem to be working now. :)
     
    tdoggy, Dec 14, 2007 IP