每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 &

原文地址:https://www.cnblogs.com/carbon3/p/5906437.html