php自动(自嗨)监控
创建个PHP文件丢到你网站随便地方访问,访问后不会出现结果,等待个20秒左右关闭页面,就会自动执行了,执行以后除非重启PHP服务或者直接重启服务器,不然会一直嗨下去
<?php
//设置脚本运行不超时
set_time_limit(0);
//即使浏览器关闭还继续运营
ignore_user_abort(true);
//睡眠5秒
sleep(5);
//要监控的网址
$cronurl = 'https://www.baidu.com/';
//开始get监控
httpGet($cronurl);
//这里还可以无限加httpGet("网址");一次性多嗨几个
//获取当前文件的访问url
$url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
//开始get自己,简称自嗨,达到无限循环的效果
httpGet($url);
//发起GET模拟请求
function httpGet($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER,array('Accept-Encoding: gzip, deflate'));
curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate');
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (iPhone; CPU iPhone OS 8_0 like Mac OS X) AppleWebKit/600.1.3 (KHTML, like Gecko) Version/8.0 Mobile/12A4345d Safari/600.1.4");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 3);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
转自烟雨云博客原文链接https://www.yyhy.me/1833.html
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 七云's Blog!