Results 1 to 2 of 2
Hello. I have wrote a simple perl script (see below) that executes a RAID status command on a remote machine over and emails the output of the command to me. ...
- 02-07-2011 #1Just Joined!
- Join Date
- Feb 2011
- Posts
- 1
Perl script not running from cron
Hello. I have wrote a simple perl script (see below) that executes a RAID status command on a remote machine over and emails the output of the command to me. I can run the script locally and see the command output in my email body, but if I create a cron job the email message body is blank. I assume it's something like cron not having permissions to execute the command within the script. I have the script set to -rwxr-xr-x (755) and owner is root so cron should be able to run everything. Please advise guys. Thanks!
Code:#!/usr/bin/perl my $cmd = `ssh -l root 10.0.0.1 tw_cli /c4 show`; use Mail::Sendmail; %mail = ( To => 'me', From => 'raidstatus', Subject => "Raid Status", Message => "$cmd" ); sendmail(%mail) or die $Mail::Sendmail::error;
- 02-07-2011 #2Linux Newbie
- Join Date
- Mar 2009
- Posts
- 228
When a script runs fine locally but not in cron it indicates a difference in environments. Remember that cron does NOT run you login profile script(s) before running the script. Often PATH is the problem. When writing a script that is to be run in cron specify the full path for the commands.
Instead of:
ssh
it should be:
/path/to/ssh


Reply With Quote