跳至主要內容
pm2定时推送到git仓库及定时执行mongo备份

安装pm2

安装node

https://nodejs.org/dist/v16.15.0/node-v16.15.0-x64.msi 一直next即可

安装pm2

npm install -g pm2

编写git推送py脚本

import os
import time

# 获取当前时间
now_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())


def callback(result):
    os.system(result)


# add the file
add = "git add ."
# commit the file
commit = "git commit -m 'auto commit: {}'".format(now_time)
# push the file
push = "git push origin master"
callback(add)
callback(commit)
callback(push)

爱喝水的木子...小于 1 分钟pm2pm2crontab