zoukankan      html  css  js  c++  java
  • 每30秒运行一下shell脚本

    cd /usr/local/sbin/     //存放shell脚本 目录。

    vim guoguosql.sh      //每30秒运行一个php文件。   文件路径为 vim /home/wwwroot/www/domain/huitiao/web/sql.php

    #! /bin/bash
    while :; do
            curl http://127.0.0.1:82/sql.php
            sleep 30
    done

    sh /usr/local/sbin/guoguosql.sh &    //运行 放入后台运行

    vim /etc/rc.d/rc.local       //加入开机启动  在最后加入:

    sh /usr/local/sbin/guoguosql.sh &          //后面用 nohup

    停止shell

    [root@zh-19-46 sbin]# ps aux|grep guoguosql
    root 22899 0.0 0.0 106072 1316 pts/0 S 17:36 0:00 sh /usr/local/sbin/guoguosql.sh
    root 33419 0.0 0.0 103316 908 pts/0 S+ 17:49 0:00 grep guoguosql

    kill 22899

    ----------------------------------------------之前会自己关了程序

    nohup命令及其输出文件

    nohup命令:如果你正在运行一个进程,而且你觉得在退出帐户时该进程还不会结束,那么可以使用nohup命令。该命令可以在你退出帐户/关闭终端之后继续运行相应的进程。nohup就是不挂起的意思( n ohang up)。

    该命令的一般形式为:nohup command &   

    nohup /usr/local/sbin/guoguosql.sh &

  • 相关阅读:
    MyEclipse中无法将SVN检出来的项目部署到tomcat中
    Hibernate n+1问题
    Dubbox框架和Zookeeper 依赖的引入
    SpringSecurity安全框架
    order
    旅游网数据库
    教学所用
    权限系统设计五张表
    springMVC上传文件
    web 开发流程
  • 原文地址:https://www.cnblogs.com/carbon3/p/5906437.html
Copyright © 2011-2022 走看看