What am I overlooking here?
You are overlooking what the current directory is when running the cron script. Set up a trivial cron job which just prints the current working directory and then you will know. It's usually $HOME unless you change it.
There are, as usual, so many ways to tackle this. My usual approach is to have cron run a shell script which does all the set-up (change to the right directory, populate the environment etc.) and then at the last have that script exec the perl script. I've found this to be robust and secure (in that it doesn't leak any info). You can have the same shell script (or 2 copies of the same script) for both test and prod and just pass it a different argument to choose which path to run. eg:
#!/bin/bash if [ "$1" == 'prod' ]; then cd $HOME/website/prod else cd $HOME/website/test fi export DOCUMENT_ROOT=./www exec ./lib/maintain.pl
And in your crontab call it like
30 5 * * * $HOME/website/prod/maintain.sh prod
I do find it slightly odd that you have scripts in your lib dir. I tend to keep all my cron jobs in a cron dir for clarity.
🦛
In reply to Re: use lib "."
by hippo
in thread use lib "."
by Bod
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |