Search code examples
linuxbashshellazcopy

When scheduled with cron, ./azcopy does not run


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/abc\home\xyz?"

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/abc\home\xyz?<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

  • 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.