I've written a shell script that does the following:

  • Retrieve mail from a POP3 account (using GetMail)
  • Save a copy of that email to S3 (using AWS CLI)
  • Email me the filesize of the email

The script runs fine manually, and technically runs from CRON, but it only seems to be sending the email. The getmail and S3 bits don't seem to run.

Everything I've read seems to hammer home the message that I need to be careful about relative paths and the like when using CRON, but I think I'm using absolute paths everywhere I need to be, so I'm stumped as to what the issue could be.

My Shell Script is here:


# Run GetMail
getmail -r /PATH/TO/EMAIL/getmail.email

# Save to S3
aws s3 cp /PATH/TO/SCRIPT/email-backup.mbox s3://XXXXXXXXXX/email-backup.mbox 

# Send Confirmation Email


# Get current filesize
FILESIZE=$(stat -c%s "$FILENAME")

# Email Content
echo "Current File Size: $FILESIZE bytes" >>$EMAILMESSAGE

# Send the Mail
/bin/mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE

I've had a similar problem, because CRON can be quite finicky. My best guess would be that you need to add the path to the aws command, for instance:

/usr/local/bin/aws s3 cp /PATH/TO/SCRIPT/email-backup.mbox s3://XXXXXXXXXX/email-backup.mbox 

Good Luck!

| improve this answer | |
  • This did it, thanks! I was so preoccupied with paths to scripts I hadn't even considered paths to commands. Really appreciate the help! – binaryorganic Jun 3 '14 at 19:57
  • Excellent. Not a problem. – paranoid Jun 3 '14 at 21:53

Not the answer you're looking for? Browse other questions tagged or ask your own question.