Dear all,
I wish to let cron executes delete_snapshot.bash, but when I try to create cron as below:
*/1 * * * * /var/www/mango_gis/delete_snapshot.bash >/dev/null
It didn't execute my script at all, because when I didn't see it delete the snapshot in the amazon cloud, and my script is already tested with bash, it work fine.
Here is my script as below:
#!/bin/bash
get()
{
local pos=$1
shift
eval 'echo ${'$pos'}';
}
length(){ echo $#; }
find_snapshots()
{
echo $(ec2-describe-snapshots | xargs -n1 basename);
}
snapshots=$(find_snapshots)
len=$(length $snapshots)
row_count=$(($len/6))
if(($row_count > 6)); then
delete_count=$(($row_count-6))
for (( i=1; i<=$delete_count; i++ )); do
ec2-delete-snapshot $(echo $(get $((2+$((6*$(($i-1)))))) $snapshots)) > /dev/null
done
fi
In above, I have found the problem is that I call one command of EC2 command.
I have tested to create one cron job to call this command is ec2-describe-snapshots,
but it doesn't work.
Please advise...
Leakhina