0

It may be duplicate because there is some similar question but I am not able to fix it, that's why I ask again with my code.

My sh have these code:

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

when i run it as:

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

Then its always show as:

-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

please help me.

4
  • @Martin git is not working because cd /home/domain.com/data/domain-statistics is not working
    – Shiv Singh
    Sep 14, 2021 at 7:54
  • just saw that, too - I missed that. But why do you assume that this directory should exist, and should contain a git repo ?
    – Martin
    Sep 14, 2021 at 7:55
  • these all codes working if i run by direct in terminal
    – Shiv Singh
    Sep 14, 2021 at 8:13
  • check for typos inside the directory path ... I can't think of anything else which might be wrong in this case
    – Martin
    Sep 14, 2021 at 8:43

2 Answers 2

0

I have no reputation to comment, so I write it as an answer. Have you tried the cd command using relative path instead? If I am not wrong this would be:

cd ../domain-statistics
0

these all codes working if i run by direct in terminal

So if you're not running in your terminal, then how is it being run?

If it's being run under some other user, then that user may well not have access to that directory (or one or more of its parent directories).

Examine the permissions on each directory in the path /home/domain.com/data.

2
  • You can see my question how j am running it by sh file, I am using by sh file because I need to run it every 10 minutes. So I am using by cron job.
    – Shiv Singh
    Sep 15, 2021 at 10:08
  • A cron job for /which/ user? Every user, not just root, can have their own cron jobs and each will run in the security context of the owning user. Also, cron jobs notoriously run without the usual profile settings for the user account. Assuming that this is for the same user and cron is, therefore, a Red Herring - You did not address my question about file system permissions.
    – Phill W.
    Sep 15, 2021 at 11:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .