每30秒运行一下shell脚本

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了每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 &  

停止shell

[[email protected] 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

以上是关于每30秒运行一下shell脚本的主要内容,如果未能解决你的问题,请参考以下文章