• 自动化部署


    1、编写需要执行的shell脚本:
    // 大意:先杀掉进程,再清除日志,再重启jar服务
    echo "重启webSocket" pidlist=`ps -ef |grep SystemCommunication |grep -v "grep"|awk '{print $2}'` kill -9 $pidlist rm $webSocket_home/nohup.out nohup /home/software/jdk1.8.0_221/bin/java -jar /home/SystemCommunication.jar > /home/utry/nohup.out &

    2、设置定时任务:

    crontab -e  // 编辑Linux定时任务配置文件
    
    05 16 * * * /home/webSocketStart.sh
    
    crontab -l  // 查看当前所有的定时任务
    
    05 16 * * * /home/webSocketStart.sh

    3、查看定时任务日志:

    tail -f /var/log/cron
    
    Oct 21 16:02:16 localhost crontab[12132]: (root) END EDIT (root)
    Oct 21 16:02:37 localhost crontab[12166]: (root) LIST (root)
    Oct 21 16:03:01 localhost crond[675]: (root) RELOAD (/var/spool/cron/root)
    Oct 21 16:03:01 localhost CROND[12249]: (root) CMD (/home/utry/webSocketStart.sh)
    Oct 21 16:04:01 localhost crontab[12392]: (root) BEGIN EDIT (root)
    Oct 21 16:04:22 localhost crontab[12392]: (root) REPLACE (root)
    Oct 21 16:04:22 localhost crontab[12392]: (root) END EDIT (root)
    Oct 21 16:05:01 localhost crond[675]: (root) RELOAD (/var/spool/cron/root)
    Oct 21 16:05:01 localhost CROND[12503]: (root) CMD (/home/utry/webSocketStart.sh)
    Oct 21 16:09:44 localhost crontab[12982]: (root) BEGIN EDIT (root)
    Oct 21 16:12:19 localhost crontab[12982]: (root) REPLACE (root)
    Oct 21 16:12:19 localhost crontab[12982]: (root) END EDIT (root)
    Oct 21 16:13:01 localhost crond[675]: (root) RELOAD (/var/spool/cron/root)
    Oct 21 16:14:07 localhost crontab[13419]: (root) BEGIN EDIT (root)
    Oct 21 16:14:38 localhost crontab[13419]: (root) REPLACE (root)
    Oct 21 16:14:38 localhost crontab[13419]: (root) END EDIT (root)
    Oct 21 16:14:41 localhost crontab[13456]: (root) LIST (root)
    Oct 21 16:15:01 localhost crond[675]: (root) RELOAD (/var/spool/cron/root)
  • 相关阅读:
    ASP.Net MVC-Web API使用Entity Framework时遇到Loop Reference
    springboot-32-使用mvc测试
    docker-dockerfile使用
    java-jmx使用
    docker-使用ali云加速
    docker-基础命令
    centos7-使用nginx做ftp站
    maven-插件-不同的开发环境指定
    maven
    mysql-定时对表分区
  • 原文地址:https://www.cnblogs.com/dk1024/p/13853002.html
Copyright © 2020-2023  润新知