DEV Community

Mahfuz Shaikh
Mahfuz Shaikh

Posted on

1 1

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.

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay