perl system function not working if executed through cron

Viewed 90

crontab

* * * * * /temp/feroz/daemon/sync_ec2_s3.sh >> /temp/feroz/daemon/cronlog.txt 2>/temp/feroz/daemon/cronlog.error.txt

cron script /temp/feroz/daemon/sync_ec2_s3.sh

#!/bin/sh
cd /temp/feroz/daemon
/usr/local/bin/perl sync_ec2_s3.pl -vx

sync_ec2_s3.pl

my $cmd = "aws s3 cp $lockfile $s3_lockfile";
print "Step 1 $cmd \n";
my $rc = system($cmd);
print "SUCCESS <$rc> \n";
  1. If sync_ec2_s3.sh is executed via cron as shown above, system command doesn't work, and I am getting a result of -1 in $rc.

  2. If script execute manually as sh sync_ec2_s3.sh, then system commands works fine.

Please help me to understand why it is not working through cron, and what I have to do to resolve

1 Answers

You should check that the aws command is in your path, or write the full path to the aws command.

Related