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:
#!/bin/bash
# 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
SUBJECT="
EMAIL SUBJECT"
EMAIL="
[email protected]"
# Get current filesize
FILENAME=/PATH/TO/SCRIPT/email-backup.mbox
FILESIZE=$(stat -c%s "$FILENAME")
#
Email Content
EMAILMESSAGE="/tmp/emailmessage.txt"
echo "
EMAIL BODY" >$EMAILMESSAGE
echo "" >>$EMAILMESSAGE
echo "Current File Size: $FILESIZE bytes" >>$EMAILMESSAGE
# Send the Mail
/bin/mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE