M
M
mirexdoors2018-09-19 12:15:05
git
mirexdoors, 2018-09-19 12:15:05

How to autocommit on cron?

Hello! I went along the following path:
- in the folder of the sudo-user "sudouser" /home/sudouser/scripts I placed commit.sh with the following content:

#!/bin/bash
cd /var/www/domain/data/www/test.domain.ru && git add .
cd /var/www/domain/data/www/test.domain.ru && git commit -a -m 'autocommit'
cd /var/www/domain/data/www/test.domain.ru  && git push origin master

- added this script to the crontab
- added the ssh key to the bitbucket
- ...
-no profit =(
When manually running ./commit.sh, the repository files are created mod (that is, if I understand correctly, a commit is created) and the following is thrown out :
Warning: Permanently added the RSA host key for IP address 'XX.XXX.XX.XXX' to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Accordingly, changes to the repository do not come. The question is, why can't get the remote repo? SSH is incorrect?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem, 2018-09-19
@ulkoart

Most likely the cron is being executed by a different user than the user whose key was added.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question