使用 crontab 来定时执行.sh 把文件备份到 github,会出现有时需要手动执行一次“ssh-agent bash”在执行.sh 才成功,有时就不用,以下是错误内容和.sh 源码 ###报错内容:
Could not open a connection to your authentication agent.
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
###.sh 文件内容
#!/bin/bash
cd /root/mc/worlds
git add -A
git commit -m "backup"
ssh-add /root/github
git push -u origin master