php 每分钟定时任务

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4901335/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 16:13:18  来源:igfitidea点击:

Cronjob every minute

phpmysqlcron

提问by good_evening

I have a file in mysite.com/url1/url2/cronjob.php which has to be run every minute. I try every combination, but can't succeed. What should I run in command line? Thank you.

我在 mysite.com/url1/url2/cronjob.php 中有一个文件,必须每分钟运行一次。我尝试了每种组合,但都无法成功。我应该在命令行中运行什么?谢谢你。

回答by Linus Kleen

In case you'd set it up in a crontab, this works:

如果你在 crontab 中设置它,这有效:

*/1 * * * * /usr/bin/wget -O /dev/null http://example.com/cron.php

回答by стрив?гор

The PHP interpreter.

PHP 解释器。

/[path-to-php]/php -f [your-php-script]

回答by Ish

Steps your shell

步骤你的外壳

$ crontab -e


* * * * * php -f /path/to/cron.php
~
~

回答by madhu131313

I got confused for the first time where to add all of these and finally found.

我第一次对在哪里添加所有这些感到困惑,终于找到了。

Type the following in the linux/ubuntu terminal

在 linux/ubuntu 终端中输入以下内容

 crontab -e 

select an editor (sometime it asks for the editor) and this to run for every minute

选择一个编辑器(有时它会要求编辑器)并且每分钟运行一次

*       *       *       *       *       /usr/bin/php path/to/cron.php &> /dev/null

回答by Allan N?rgaard

Are you looking for help to make an UNIX cronjob?

您是否正在寻求帮助来制作 UNIX cronjob?

If so, have you tried to edit /etc/crontab, and add

如果是这样,您是否尝试过编辑 /etc/crontab,并添加

 * * * * user command

where user is either root or your name. Im not exactly sure how to access and URL, but a dirty way could involve downloading the link as a file, e.g. "wget http://url.com/page.php"

其中 user 是 root 或您的姓名。我不确定如何访问和 URL,但一种肮脏的方式可能涉及将链接下载为文件,例如“wget http://url.com/page.php