Usually cron will send you a message with the output of your program. When you find out, you probably want to check the environment. This will not necessarily be the same environment as your login shell (since it is not a login shell):
foreach my $key ( keys %ENV ) { printf "$key: $$ENV{$key}\n"; }
If you are missing something you need, install it in your crontab:
SOME_VAR=some_value HOME=/Users/Buster
If you need to start in a specific directory, you should chdir there. The initial directory from the cron job is probably not the one you think so. Without an argument, chdir changes to your home directory. However, sometimes these environment variables cannot be set in your cron session, so it is probably best to have a default value:
chdir( $ENV{HOME} || '/Users/Buster' );
At different critical points you should give an error message. This is good even in programs other than cron:
open my $fh, '<', $some_file or die "Didn't find the file I was expecting: $!";
If you redirect things to / dev / null, you lose all the information that may help you solve the problem.
source share