I have seen other questions that are similar but I can't find any real information on how to figure out the proper way to run a Bash script via Crontab. The .sh
file is located in the user directory (in my case serverpilot
).
The script is trying to copy the contents of the apps
folder and send to my S3 bucket. The script works perfectly when run with sh backupS3.sh
from the terminal but no joy via Cron. I've seen people reference PATH variables and the like but no idea where to even begin!
/backupS3.sh
#!/bin/sh
echo 'Started backing to S3'
date +'%a %b %e %H:%M:%S %Z %Y'
aws s3 sync /apps s3://bucketname
date +'%a %b %e %H:%M:%S %Z %Y'
echo 'Finished backing to S3'
crontab
*/10 * * * * /backupS3.sh >> backupS3.log
Can anyone point me at anything obvious I'm doing wrong? Thanks!
EDIT: I've added 2>&1 on to the end of the cron command and now I am getting something in the log file:
/bin/sh: 1: /backupS3.sh: not found