Bash

Why bash script does not work on crontab

but works when run directly.

Donald Le
1 min readJan 22, 2021

--

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

--

--

Donald Le

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