I'm trying to automate my some task in Amazon linux
All of my file location is /home/ec2-user/ (CRON, bash.sh)
Here is my command (I just executed this command in /home/ec2-user/)
sudo yum install -y python3 && sudo yum install -y cronie && chmod 777 bash.sh && crontab CRON && sudo service crond restart
my cron file name: CRON
and here is my code
* * * * * /bin/bash /home/ec2-user/bash.sh
my bash file name: bash.sh
and here is my code
#! /bin/bash
python3 - << 'EOF'
print("test")
EOF
but after one minutes later, I got one mail with contains error message
From ec2-user@ip-172-31-45-45.ap-northeast-2.compute.internal Wed Jul 20 01:56:01 2022
Return-Path: <ec2-user@ip-172-31-45-45.ap-northeast-2.compute.internal>
X-Original-To: ec2-user
Delivered-To: ec2-user@ip-172-31-45-45.ap-northeast-2.compute.internal
Received: by ip-172-31-45-45.localdomain (Postfix, from userid 1000)
id 10D63816BBE; Wed, 20 Jul 2022 01:56:01 +0000 (UTC)
From: "(Cron Daemon)" <ec2-user@ip-172-31-45-45.ap-northeast-2.compute.internal>
To: ec2-user@ip-172-31-45-45.ap-northeast-2.compute.internal
Subject: Cron <ec2-user@ip-172-31-45-45> /bin/bash /home/ec2-user/bash.sh
Content-Type: text/plain; charset=ANSI_X3.4-1968
Auto-Submitted: auto-generated
Precedence: bulk
X-Cron-Env: <XDG_SESSION_ID=6>
X-Cron-Env: <XDG_RUNTIME_DIR=/run/user/1000>
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/home/ec2-user>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=ec2-user>
X-Cron-Env: <USER=ec2-user>
Message-Id: <20220720015601.10D63816BBE@ip-172-31-45-45.ap-northeast-2.compute.internal>
Date: Wed, 20 Jul 2022 01:56:01 +0000 (UTC)
: No such file or directoryash.sh
I think my CRON file fail to find /home/ec2-user/bash.sh
How can I solve this problem?
Thank you for reading my article.