使用CRON作业来访问URL? [英] Using CRON jobs to visit url?

查看:122
本文介绍了使用CRON作业来访问URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Web应用程序,它必须执行重复的任务,发送消息和警报,我已经使用脚本页面将其加载到浏览器中时执行了这些任务,即 http://example.com/tasks.php .但是,我不希望这个CRON作业创建输出文件,例如day.*!

我将应用程序托管在允许通过cPanel进行CRON作业的共享托管服务上.

解决方案

* * * * * wget -O - http://yoursite.com/tasks.php >/dev/null 2>&1

那应该对您有用.只需使用wget脚本加载页面即可.

使用-O -表示Web请求的输出将发送到STDOUT(标准输出)

通过添加>/dev/null,我们指示将标准输出重定向到黑洞. 通过添加2>&1,我们指示还将STDERR(错误)发送到STDOUT,因此所有输出都将发送到黑洞. (这样它将加载网站,但永远不会在任何地方写文件)

I have a web application that has to perform a repeated tasks, Sending messages and alerts, I, already, use a script page do those tasks when it loaded in the browser i.e http://example.com/tasks.php and I included it by the mean of iframe in every page of my web application.

Now I want to change this to use CRON jobs because the first approach may leads to jam performance, So How could I make a CRON job that visits http://example.com/tasks.php. However, I don't want this CRON job creating output files such as day.*!

I host the application on shared hosting service that permits CRON jobs via cPanel.

解决方案

* * * * * wget -O - http://yoursite.com/tasks.php >/dev/null 2>&1

That should work for you. Just have a wget script that loads the page.

Using -O - means that the output of the web request will be sent to STDOUT (standard output)

by adding >/dev/null we instruct standard output to be redirect to a black hole. by adding 2>&1 we instruct STDERR (errors) to also be sent to STDOUT, and thus all output will be sent to a blackhole. (so it will load the website, but never write a file anywhere)

这篇关于使用CRON作业来访问URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆