DEV Community

Mahfuz Shaikh
Mahfuz Shaikh

Posted on

Please Help me out on Bash script CRON

Hey folks how are you doing. Need a help.
I have a bash script to backup MySQL databases, that runs on a daily cronjob. Everything is working fine as intended but only there is an error on S3 upload part. The script is working good on manual execution but the cronjob execution says:
s3: command not found
The S3 upload code is below.

S3_BUCKET="s3-bucket-name"
AWS="$(which aws)"
$AWS s3 cp backups.tar.gz s3://${S3_BUCKET}

Any help would be appreciated. Thanks all.

Top comments (3)

Collapse
 
mah3uz profile image
Mahfuz Shaikh • Edited

Though it's working, I am curious if those work on cron

which mysql
which mysqldump
which gzip

why which aws this is not working, I mean what I am missing?
aws is on /usr/local/bin/aws

 
mah3uz profile image
Mahfuz Shaikh

Yeah, it's complicated but you explain well thanks a lot.

Collapse
 
mah3uz profile image
Mahfuz Shaikh

Thank you so much @imadityang its work. You save my day.