武汉SEO
时光静好,与君语;细水流年,与君同;繁华落尽,与君老...

个人日记>正文

求大佬 给一个用shell访问一个URL的脚本

2021-04-03 16:09 gbl

<?php

ignore_user_abort(true);//忽略浏览器与服务器的交互

set_time_limit(0);

$sleep = 2;//间隔的时间 秒

$url='http://baidu.com/';//要访问的地址

$confFile = './http.conf.txt';//配置文件

$logFile = './http.log.txt';//日志保存

 

if(!file_exists($confFile)){

    //创建配制文件

    file_put_contents($confFile, 0);

}

do{

    if(file_get_contents($url)){

        file_put_contents($logFile,'[OK]'.date('Y/m/d H:i:s').PHP_EOL,FILE_APPEND);

        echo 'OK';

    }else{

        file_put_contents($logFile,'[FAIL]'.date('Y/m/d H:i:s').PHP_EOL,FILE_APPEND);

        echo 'Fail';

    }

    sleep($sleep);

}while(file_get_contents($confFile)==0);

粘贴保存为.php文件,放到web目录,然后访问,当浏览器处于挂起状态时关闭浏览器既可, 如果需要关闭,修改配置文件中的0为其他任意内容既可以在下次循环时停止。

本文链接:https://www.0937.biz/post-3137.html

图文推荐
热门标签