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 &