Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backup doesn't work under cron #133

Open
kmfreas opened this issue Jul 14, 2016 · 4 comments
Open

Backup doesn't work under cron #133

kmfreas opened this issue Jul 14, 2016 · 4 comments

Comments

@kmfreas
Copy link

kmfreas commented Jul 14, 2016

Hi there,

Love the script, it seems to work great when I run it normally. I'm having an issue with it not running in a cron job. I've checked many other related issues and didn't see anything directly related to my issue. I have to admit that I'm not the most familiar with cron jobs, so it could be something I just haven't done yet.

This is what I'm running from crontab -e, as user ubuntu (running it every minute temporarily until I get it working):
* * * * * /home/ubuntu/ec2-automate-backup.sh -r us-east-1 -s tag -t Backup,Values=true -k 7 -p -n -c /home/ubuntu/cron-primer.sh >> /home/ubuntu/backup.log

This is my cron-primer.sh. I added /usr/local/bin to the path as per this issue
#!/bin/bash -
# export PATH=/bin is required for cut, date, grep
# export PATH=/usr/bin is required for AWS Command Line Interface tools
export PATH=/bin:/usr/bin:/usr/local/bin

# AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY needed for AWS CLI tools
export AWS_ACCESS_KEY_ID=xxxxxx
export AWS_SECRET_ACCESS_KEY=xxxxx

# AWS_CONFIG_FILE required for AWS Command Line Interface tools (f.e. ".aws")
export AWS_CONFIG_FILE=/home/ubuntu/.aws/config

Thanks for looking!

@kmfreas kmfreas closed this as completed Jul 14, 2016
@kmfreas kmfreas reopened this Jul 14, 2016
@insiderq
Copy link

same issue

@insiderq
Copy link

I spent a damn load of time trying to resolve this issue.

The problem was in aws tool located in /usr/local/bin insted of /usr/bin, but somehow my script does not catch/execute cron-primer file, even if i specify it with -c /path/to/cron-primer.sh. So editing that was unsuccessfull.

In addition my command seems to redirect only STDOUT output to log file only and when error had place i saw an empty file that pissed me off.

As a final workaround-solution i just used sudo ln -s /usr/local/bin/aws /usr/bin/aws and everything went good.

@claytonmorrow
Copy link

I had the same issue - it does not seem to be reading the cron-primer file. Maybe there is a change that is breaking it, because I have used this script in the past in different situations without issue.

My quick workaround to get it working with Cron was to export the path export PATH=/usr/local/bin at the top of ec2-automate-backup.sh

@bereska
Copy link

bereska commented Dec 5, 2017

ran into the same issue, had a lot of fun playing with crontab until I found aws was in ~/bin
long story short sudo ln -s /home/ubuntu/bin/aws /usr/bin/aws SOLVED it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants