Issue
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"
It works perfectly if I run it from the shell, but does nothing with Cron. Why? I am using IAM roles, is it important?
Solution
Ok, after several hours I found the solution:
The user root was running the script but AWS was not configured for this user. I only needed to configure AWS for the user root:
# aws configure
Answered By - Medical physicist Answer Checked By - Terry (WPSolving Volunteer)