When scheduled with cron, ./azcopy does not run
Problem Description:
There is a shell script in the location /file/location/azcopy/, and an Azcopy binary is also located there
The below command runs successfully when I run it manually
./azcopy cp "/abc/def/Goa.csv" "https://.blob.core.windows.net/abchomexyz?"
However, when I scheduled it in crontab, the "./azcopy" command didn’t execute.
below is the script
#!/bin/bash
./azcopy cp "/abc/def/Goa.csv" "https://<Blobaccount>.blob.core.windows.net/abchomexyz?<SAS- Token>"
below is the crontab entry
00 17 * * * root /file/location/azcopy/script.sh
Is there something I’m doing wrong?
Could someone please help me figure out what’s wrong.
Solution – 1
When you use root to execute the /file/location/azcopy/script.sh
,you work directory is /root
,so you need to add cd /file/location/azcopy/
in your script.sh
script to change work directory. You can add pwd
in your script to see the current work directory.