I’m trying to run a perl script on my Ubuntu server using cron. I have 3 perl scripts:
- works.pl (Works from the terminal. Works as a cron job)
- fails.pl (Works from the terminal. Fails as a cron job)
- functions.pl (all my shared functions are stored in here)
The only difference I can think of between ‘works.pl’ and ‘fails.pl’, is that ‘fails.pl’ uses the require() statement that references ‘functions.pl’. ‘Fails.pl’ does not reference ‘functions.pl’.
Extra info
- All of my perl scripts are located in the same folder, which is
outside of my public folder. - All of my perl scripts have the same permissions (740).
Any ideas? My user level is novice btw 🙂
Thanks.
requiretries to find the script in one of the directories listed in the@INCarray. This array usually contains the current directory,.. Therefore if your current directory is the one thatfunctions.plis located in then runningfails.plshould work.There are two ways to achieve this: First, change the directory before running the script, e.g. (cron entry example)
Second, tell Perl where to find your script at compile time by putting this near the top of
fails.pl: