Why bash script does not work on crontab

but works when run directly.

Recently I met an issue that my shell script does not run in crontab. But when I run them directly it works. For example consider this bash:

#!/usr/bin/env bash
aws ec2 stop-instances --instance-ids i-0cebb331ce02934a i-08c55f40aadfa64e i-09aeaec43de5e67e i-09a63f61a682f8d9 i-049cfae6dd25b799

Works perfectly fine when run

./stop-instances.sh

--

--

--

A passionate automation engineer who strongly believes in “A man can do anything he wants if he puts in the work”.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Development Update: 10/25

Communication between game objects using scripts

Campaign Manager Command Line Report Inspecting Tool

Scheduled Tasks: The Good Way (or: Why You Should Stop Using Crontab)

Terraform 101 — Part 1/4: History, Workflow and Resource Addressing

Process Azure Analysis Services Models with Azure Data Factory v2

Match 3 Algorithm with Regular Expression

Monotonic Queue for Sliding window Maximum

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Donald Le

Donald Le

A passionate automation engineer who strongly believes in “A man can do anything he wants if he puts in the work”.

More from Medium

How to write multi-stage Dockerfile

Order up! Learn how Concentrix Catalyst is redefining “fast food” with emerging tech

What Makes Linux a Better Choice of Operating System than Windows?

what makes linux a better choice?

Bash Commands Cheat Sheet for Developers

Bash Commands Cheat Sheet for Developers