I have gone through similar posts in this website, but none of them is matching my query.

I have the below content in my crontab, but it is not working.

 * * * * * perl sc.pl

And when i'm trying manually like below,i'm getting output.

**perl sc.pl**

Please help me to solve this issue.

  • 1
    This post is seriously lacking in details. Post the complete cron, the output of the command, the error in the log if any, the output of the command, and what you are trying to do. It maybe have to do with perl not being in the default path of cron or/and with the path as the perl libraries (tipically with libraries installed with CPAN) and you may also have to redirect the output of the command to /dev/null when you get it working. – Rui F Ribeiro Dec 12 '15 at 11:32
  • 2
    Cron's environment is very different from yours. Cron doesn't know what your current working directory is. Do this: /usr/bin/perl /full/path/to/sc.pl – glenn jackman Dec 14 '15 at 13:41

As @glenn jackman mentions, you will typically need to specify at least the absolute path to the files in your arguments, and often the full path to the executable as well.

The process attempting to run your program (cron, your current shell/terminal, etc) will have a PATH variable in your environment specifying what directories to look in for executables (such as perl). Running executables typically base relative paths (or filenames with no path) on the current working directory and do not search for them or magically know where they are. The cron job will typically not have the identical path variable to your interactive terminal sessions, and may not be starting in the same directory as your script file (especially if you have to cd into a directory before you manually run perl sc.pl)

Our first suggestion would be to try absolute paths to the perl binary and the sc.pl script. Example:

* * * * * /usr/bin/perl /path/to/sc.pl

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.