実行中のshファイルにはそのようなファイルまたはディレクトリはありません

実行中のshファイルにはそのようなファイルまたはディレクトリはありません

類似の質問がいくつかあるため重複している可能性がありますが、修正できないため、自分のコードを使用して再度質問します。

私のshコードは次のとおりです:

cd /home/domain.com/data/domain-statistics
git fetch origin
git merge origin/master
git add --all
git add .
git commit -am "File generated and updated on `date`"
git push origin master

次のように実行すると:

-bash-4.2$ sh /home/domain.com/data/crons/push.sh

すると、常に次のように表示されます:

-bash-4.2$ sh /home/domain.com/data/crons/push.sh
/home/domain.com/data/crons/push.sh: line 1: cd: /home/domain.com/data: No such file or directory
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git

私を助けてください。

答え1

コメントするほどの評判がないので、回答として書きます。代わりに相対パスを使用して cd コマンドを試しましたか? 間違っていなければ、次のようになります:

cd ../domain-statistics

答え2

ターミナルで直接実行すると、これらのコードはすべて機能します。

だからもしあなたは走っていないあなたのターミナル、それではどうですかいる走る?

もしそれが何らかの他のユーザーの場合、そのユーザーはないそのディレクトリ (またはその親ディレクトリの 1 つ以上) にアクセスできます。

パス内の各ディレクトリの権限を調べます/home/domain.com/data

関連情報