php 使用 Webmin 设置 cron 作业
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5832511/
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
Setting up a cron job with Webmin
提问by John
I am trying to setup a Cron job using Webmin to run every 5 min. It needs to target a .php file and run the php script in that file. When I enter the path to the file in the "Command" field, it doesn't work. I am just wondering what I am doing wrong, and where do I put the file path that I need the Cron job to run.
我正在尝试使用 Webmin 设置一个 Cron 作业,每 5 分钟运行一次。它需要定位一个 .php 文件并在该文件中运行 php 脚本。当我在“命令”字段中输入文件的路径时,它不起作用。我只是想知道我做错了什么,我把需要 Cron 作业运行的文件路径放在哪里。
Thanks!
谢谢!
回答by Naresh Kumar Nakka
System -> Scheduled Cron Jobs
Click Create a new scheduled cron job
.In Command box enter /usr/bin/php -q /var/www/path/to/your_php_script.php
Click "Times and dates selected below .." radio button
Click "Selected.." under Minutes section
Select 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55 (use control key) and click 'Save' button
.
System -> Scheduled Cron Jobs
Click Create a new scheduled cron job
.In Command box enter /usr/bin/php -q /var/www/path/to/your_php_script.php
Click "Times and dates selected below .." radio button
Click "Selected.." under Minutes section
Select 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55 (use control key) and click 'Save' button
.
回答by William Beston
Here Is A Visual Of Adding A New 5 Min. Int. Cron Job In Webmin version 1.610.
这是添加新 5 分钟的视觉效果。国际。Webmin 版本 1.610 中的 Cron 作业。
回答by Matthew
Put it in the "command" SLE (single line entry) field. When you reach the scheduling page, click [Run Now] to test.
将它放在“命令”SLE(单行输入)字段中。到达调度页面后,点击【立即运行】进行测试。
By all means inspect records written (Webmin unit test) and certainly test (with a stub) the scheduling from Webmin, as some of the Webmin modules are a little flaky.
一定要检查写入的记录(Webmin 单元测试),当然还要测试(使用存根)来自 Webmin 的调度,因为某些 Webmin 模块有点不稳定。
回答by netbrain
im guessing you are running a linux environment. in that case you can run the command (through ssh/terminal) php /path/to/file.php
.
我猜你正在运行一个 linux 环境。在这种情况下,您可以运行命令(通过 ssh/终端)php /path/to/file.php
。
If this works, then now the trick is to make this a scheduled command. You can do this with crontab by typing crontab -e
This will then open a text editor which you can type something of the following:
如果这有效,那么现在的诀窍是将其设为预定命令。您可以使用 crontab 执行此操作,方法是输入crontab -e
This 将打开一个文本编辑器,您可以在其中输入以下内容:
@hourly php /path/to/file.php >/dev/null 2>&1
This will then run the command php /path/to/file.php
every hour and detatch the process.
这将php /path/to/file.php
每小时运行一次命令并分离进程。
This is the linux way of doing it, webmin may have a way of doing this through the web ui. maybe that is what you are asking?
这是 linux 的做法,webmin 可能有办法通过 web ui 来做到这一点。也许这就是你要问的?
回答by Hayden Thring
goto Webmin>System>Scheduled Cron Jabs -> 'create new scheduled cron job' and as mentioned above use php command with script as parameter to exec it
转到 Webmin>System>Scheduled Cron Jabs -> 'create new schedule cron job' 并如上所述使用带有脚本的 php 命令作为参数来执行它