使用 CRON 作业访问网址?

我有一个网络应用程序,必须执行一个重复的任务,发送消息和警报,我,已经,使用脚本页面做这些任务时,它加载在浏览器即 http://example.com/tasks.php和我包括它的意思是,在我的网络应用程序的每一个页面。

现在,我想改变这个使用 CRON 作业,因为第一种方法可能会导致拥塞性能,所以我怎样才能使一个访问 http://example.com/tasks.php的 CRON 作业。但是,我不希望这个 CRON 作业创建输出文件,如天。*!

我在共享主机服务上托管应用程序,该服务允许通过 cPanel 进行 CRON 作业。

145511 次浏览
* * * * * 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)

You don't need the redirection, use only

* * * * * wget -qO /dev/null http://yoursite.com/tasks.php

You can also use the local commandline php-cli:

* * * * * php /local/root/path/to/tasks.php > /dev/null

It is faster and decrease load for your webserver.

i use this commands

wget -q -O /dev/null "http://example.com/some/cron/job.php" > /dev/null 2>&1

Cron task:

* * * * * wget -q -O /dev/null "http://example.com/some/cron/job.php" > /dev/null 2>&1

You can use curl as is in this thread

For the lazy:

*/5 * * * * curl --request GET 'http://exemple.com/path/check.php?param1=1'

This will be executed every 5 minutes.

you can use this for url with parameters:

lynx -dump "http://vps-managed.com/tasks.php?code=23456"

lynx is available on all systems by default.

You can use this command:

links https://www.honeymovies.com

U can try this :-



wget -q -O - http://www.example.com/ >/dev/null 2>&1


* * * * * wget --quiet https://example.com/file --output-document=/dev/null

I find --quiet clearer than -q, and --output-document=/dev/null clearer than -O - > /dev/null

Here is simple example. you can use it like

wget -q -O - http://example.com/backup >/dev/null 2>&1

and in start you can add your option like (*****). Its up to your system requirements either you want to run it every minute or hours etc.

For Cron job to work you just need to hit the url, without any output and without downloading anything.

I am using only the wget with this two parameters:

*/2 * * * * wget -q --spider https://example.com/

*/2 : run every 2 minutes

‘-q’ :Turn off Wget’s output.

--spider : When invoked with this option, Wget will behave as a Web spider, which means that it will not download the pages, just check that they are there.

Documentation: https://www.gnu.org/software/wget/manual/wget.pdf