0
0
test/auto-upload.md
2024-04-30 20:53:49 +08:00

33 lines
752 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

crontab 配置文件(每 20min 上传一次):
```text
*/20 * * * * [脚本绝对路径]
```
脚本文件(记得调权限为 7xx
```shell
#!/bin/bash
source /etc/profile
cd /root
/usr/bin/git clone [仓库链接]
cd [仓库目录]
/usr/bin/git checkout [分支名]
/usr/bin/cp [测号器输出目录]/* .
/usr/bin/git add .
/usr/bin/git commit -m "auto commit"
/usr/bin/git push origin [分支名]
cd ..
/usr/bin/rm -rf [仓库目录]
```
使用前先上传 ssh 私钥并调权限,然后执行以下命令:
```shell
apt update && apt install cron
service cron start
crontab [配置文件]
```
**注意:上述配置完成后,请务必手动执行一次上传流程!否则 git 提交可能会卡在 ssh 新主机确认阶段**