zoukankan      html  css  js  c++  java
  • docker python crontab 定时任务

    背景:有10个一下定时任务,他们互补关联,需要放在server 上docker里面  run, 

    目前任务少,还未安装airflow , 临时方案

    使用:

    1.下载镜像

    sudo docker pull happysea/python:cronjob

    2. 运行镜像

    sudo docker run -itd --restart=always  --name  cronjob   happysea/python:cronjob

    3.进入容器 

    sudo docker exec -it   22421412421412  bash

    4.拷贝python 脚本

    scp  sea@127.0.0.2:/home/sea/python/xxx.py    /opt/python/

     编写脚本:略 

    5.添加cron job

    crontab -e
    #添加你需要的脚本
    0 2 * * * /home/sea/Desktop/baxiancode/start_daily_tops_service/start_daily_tops_service.sh
    #*/30 * * * * nohup  /home/sea/Desktop/MyShop/shopmonitor/shopmonitor/shopmonitor/start_shop_monitor.sh >> /home/sea/Desktop/baxiancode/shopmonitor.log 2>&1 &

    保存了crontab之后,我们还需要重启cron来应用这个计划任务。使用以下命令:

    sudo service cron restart

    crontab -l   命令列出它的全部信息

  • 相关阅读:
    COM组件
    【游戏引擎架构】入门(一)
    UNICODE字符串
    Python随笔10
    Python随笔9-函数
    Python随笔7
    Python随笔6
    Python随笔5
    Python随笔4
    Python随笔3
  • 原文地址:https://www.cnblogs.com/lshan/p/15131911.html
Copyright © 2011-2022 走看看