使用CRON作业来访问URL? [英] Using CRON jobs to visit 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屋!