I have written a small code snippet to check the aws cli version
#!/usr/bin/env bash
if [ -e "/usr/local/bin/aws" ];
then
myAWS="/usr/local/bin/aws"
else
myAWS="/usr/bin/aws"
fi
myCmd=("${myAWS} --version")
echo "$myCmd"
message=$($myCmd)
echo "$message"
Now while running this manually with root user I am able to run this script without any issue . Post our aws cli upgrade when we try to schedule this script via crontab for root user ( schedule given below)
57 21 * * * /rough/scripts/log/test.sh > /rough/scripts/log/test.log 2>&1
I face the below error , can you suggest??? I have reinstalled the aws cli but to no effect.
I understand crontab runtime environment is different than when you run a script manually but can I check whats the runtime environment that cronjob picks up. The user is root and OS is SLES.
[[Error as below]]
/usr/local/bin/aws --version
Traceback (most recent call last):
File "aws", line 19, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller/loader/pyimod02_importers.py", line 493, in exec_module
File "awscli/clidriver.py", line 43, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller/loader/pyimod02_importers.py", line 493, in exec_module
File "awscli/help.py", line 20, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller/loader/pyimod02_importers.py", line 493, in exec_module
File "docutils/core.py", line 23, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller/loader/pyimod02_importers.py", line 493, in exec_module
File "docutils/io.py", line 43, in <module>
UnicodeEncodeError: 'utf-8' codec can't encode characters in position 4-6: surrogates not allowed
[24036] Failed to execute script 'aws' due to unhandled exception!`