Amazon-Web-Services – AWS CLI cannot use cron

I have this script:

#!/bin/bash
PATH=/usr/local/ sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
SHELL=/bin/bash

# Create EBS Data snapshot
/usr/local/bin/aws ec2 create-snapshot --volume-id "vol-XXXXX" --description "test"

If I Run it from the shell, it works well, but it has no effect on Cron. Why? I am using IAM roles, is this important?

running aws configure as root user did not help me, because I have configured the credentials and the script It is very pleasant to run directly from the command line for the root user, but still cannot run through cron.
The error message I received is;

Unable to locate credentials . You can configure credentials by running "aws configure".

What helped me was to add the following line at the top of my crontab file to provide a proper environment for all scripts running through cron.

SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin: /bin

I hope someone can help!

I have this script:

#!/bin/bash
PATH=/ usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
SHELL=/bin/bash

# Create EBS Data snapshot
/usr/local/bin/aws ec2 create-snapshot --volume-id "vol-XXXXX" --description "test"

< p>If I run it from the shell, it works well, but it has no effect on Cron. Why? I am using IAM roles, is this important?

Running aws configure as root user did not help me, because I have configured the credentials, and the script runs directly from the command line for the root user very happily, but Still can’t run through cron.
The error message I received is;

Unable to locate credentials. You can configure credentials by running "aws configure". 

What helped me was to add the following lines at the top of my crontab file to provide a proper environment for all scripts running through cron.

SHELL =/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

I hope someone can help !

Leave a Comment

Your email address will not be published.