![带有 SVN 和 Git 的 Crontab](https://linux22.com/image/23373/%E5%B8%A6%E6%9C%89%20SVN%20%E5%92%8C%20Git%20%E7%9A%84%20Crontab.png)
我有一些存储库,它们都在 SVN 和 Git 中。我的用户名是 Guyfawkes,在我的主目录中我有文件夹 www,其中包含我的所有存储库。在这个目录中我还有文件 update.sh:
[guyfawkes@guyfawkes-desktop ~/www]$ cat update.sh
cd /home/guyfawkes/www
cd crm
echo "upd crm"
svn up
echo "update crm completed"
echo "-------"
cd ../crm_sql
echo "upd sql"
svn up
echo "update sql completed"
echo "-------"
cd ../crm_old
echo "upd old"
svn up
echo "update old completed"
echo "-------"
cd ../mysqldiff
echo "upd mysqldiff"
git pull sotmarket master
echo "update mysqlidff completed"
git push origin master
echo "push to github completed"
echo "-------"
cd ../mysql-migration-manager
echo "upd mmmm"
git pull
echo "mmm updated"
cd data
echo "upd data"
git pull
echo "data updated"
我的 crontab 是:
[guyfawkes@guyfawkes-desktop ~/www]$ crontab -l
*/5 * * * * /home/guyfawkes/www/update.sh
所以,它与 svn repos 完美配合,但我在 /var/spool/mail/guyfawkes 中有这些邮件(来自 cron):
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/home/guyfawkes>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=guyfawkes>
X-Cron-Env: <USER=guyfawkes>
upd crm
Fetching external item into 'public/old'
External at revision 32674.
At revision 483.
update crm completed
-------
upd sql
At revision 29.
update sql completed
-------
upd old
At revision 32674.
update old completed
-------
upd mysqldiff
Permission denied (publickey,keyboard-interactive).
fatal: The remote end hung up unexpectedly
update mysqlidff completed
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
push to github completed
-------
upd mmmm
Permission denied (publickey,keyboard-interactive).
fatal: The remote end hung up unexpectedly
mmm updated
upd data
Permission denied (publickey,keyboard-interactive).
fatal: The remote end hung up unexpectedly
data updated
我该如何修复它?
答案1
问题是您正尝试从 github 进行更新,而这需要 ssh 密钥。请在您的服务器上创建一个没有密码的专用 ssh 密钥并将其添加到您的 github 帐户,或者使用 http-readonly uri 来更新您的存储库:
git pull --mirror https://github.com/account/repository.git