The file github address! This is teach you Set boot auto start and timing execute "git pull" python-Script
以下均是在root用户下操作,步骤如下:
<!-- more -->
Set_autoGitPull_script
1.创建脚本和日志文件,这里是将脚本放在仓库下,脚本代码如下:
#!/usr/bin/python3.5
import os
os.chdir('/var/www/blog-yexiaomo/')
os.system('date >> autoGitPull.log')
os.system('sudo git pull origin master')
os.system('sudo hexo clean && sudo hexo d -g')
2.对文件进行修改权限 chomd +x autoGitPull.py
<del>3. 设定开机自运行vim /etc/rc.local在末尾添加</del>
/usr/bin/python3.5 /var/www/mysite/autoGitPull.py > /var/www/mysite/autoGitPull.log
3.设置定时运行
- 第一种方法:执行
crontab -e,末尾添加
33 3 * * * sudo /usr/bin/python3.5 /var/www/mysite/autoGitPull.py >> /var/www/mysite/autoGitPull.log &
- 第二种方法(好像不行)
vim /etc/crontab末尾添加
33 3 * * * sudo /usr/bin/python3.5 /var/www/mysite/autoGitPull.py >> /var/www/mysite/autoGitPull.log
4.重启服务 service cron restart
點(diǎn)擊查看更多內(nèi)容
為 TA 點(diǎn)贊
評(píng)論
評(píng)論
共同學(xué)習(xí),寫下你的評(píng)論
評(píng)論加載中...
作者其他優(yōu)質(zhì)文章
正在加載中
感謝您的支持,我會(huì)繼續(xù)努力的~
掃碼打賞,你說(shuō)多少就多少
贊賞金額會(huì)直接到老師賬戶
支付方式
打開(kāi)微信掃一掃,即可進(jìn)行掃碼打賞哦