Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Unable to execute bash script with cronjob rhel 9

I have created a user called abcservice with useradd abcservice --shell /usr/sbin/nologin and I have a bash script(auto.sh) with the contents:

#!/bin/bash

# Download Python script from S3 bucket
aws s3 cp s3://myscript/local_account.py /tmp/local_account.py

# Run the script
# The script will push the report to S3 bucket
sudo python3 /tmp/local_account.py

My cronjob settings are * * * * * /bin/bash /tmp/auto.sh (for testing)

For some reason, abcserviec is unable to execute the cronjob… The auto.sh has permission of 777

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I’ve check the user, group, /var/log/messages, IAM roles and policies, SELinux, and crond. The auto.sh can be executed normally manually.

>Solution :

Try this with your cronjob: * * * * * /bin/bash /tmp/auto.sh >> output.log 2>&1

I think the issue might be the AWS command in auto.sh is not set up correctly. You may need to use the full path for the AWS command in your auto.sh script. You can find the full path by running this command: which aws.

/path/to/command/aws cp s3...

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading