Plesk 中的 Crontab

发布于 2024-08-12 13:42:17 字数 499 浏览 10 评论 0原文

我正在尝试在 Plesk 中使用 crontab 运行测试脚本。 php 文件只是通过电子邮件向我发送一条消息

mail('[email protected]','Cron Test','Test');  

我的 php 路径是 /user/bin/php

我已在每个字段中输入 *,以便使用以下命令每分钟运行该脚本:

/usr/bin/php -q /usr/httpdocs/crontest.php

但是,该脚本并未运行。

有人可以帮忙吗?

我可能错过了一些简单的事情,我以前从未使用过 cron。

任何建议表示赞赏。

谢谢。

I'm trying to run a test script using crontab within Plesk. The php file simply emails me a message

mail('[email protected]','Cron Test','Test');  

My path to php is /user/bin/php

I have entered * in every field, to run the script every minute with the following command:

/usr/bin/php -q /usr/httpdocs/crontest.php

However, the script is not being run.

Can anyone help?

I'm probably missing something simple, I've never used cron before.

Any advice appreciated.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

久随 2024-08-19 13:42:17

我首先将其写入日志文件。例如:

* * * * * /usr/bin/php -q /usr/httpdocs/crontest.php >> /a-location/crontest.log 2>&1

这至少会给你任何明显的错误,比如无法找到 php 等。

I would start by getting it to write to a log file. eg:

* * * * * /usr/bin/php -q /usr/httpdocs/crontest.php >> /a-location/crontest.log 2>&1

This will at least give you any obvious errors like not being able to find php etc.

九厘米的零° 2024-08-19 13:42:17

我发现在 plesk 中使用基于用户的 cron 时,存在许多问题:

首先我发现您应该从虚拟域引用脚本。如果您的脚本的绝对地址为 /var/www/vhosts/domain.com/httpdocs/email-this.php,则应在 crontab 中将其引用为 httpdocs/email-this.php。

其次,脚本必须具有非常特殊的权限,但不确定它们“必须是什么”。 apache:apache 是对我有用的一切。即使设置了组写权限,用户仍然必须是 apache...很奇怪。

第三,进行测试的最简单方法是直接编辑 crontab,而不是每次需要进行更改时都返回到 plesk...像这样编辑您的 crontab:

crontab -u [文件系统用户名] -e

第四,我永远无法让 crontab 写入 httpdocs 之外的日志文件(我尝试了所有我能想到的统计/日志/cron_log...哈哈...没有骰子)。我最终在测试期间在 crontab 文件的顶部添加了 MAILTO 指令:

例如:

[email protected]
##      *       *       *       *       *       php -q httpdocs/cron.php

I found that when using the user based cron in plesk, there are a number of issues:

first I found that you should reference the script from the virtual domain. If your script has an absolute address of /var/www/vhosts/domain.com/httpdocs/email-this.php, you should reference it as httpdocs/email-this.php in the crontab.

Second, the script has to have very particular permissions, but not sure what they "must be." apache:apache is all that ever worked for me. Even with the group write permission set, user still had to be apache... weird.

Third, the easiest way to do the testing was to edit the crontab directly instead of going back into plesk every time I needed to make a change... Edit your crontab like this:

crontab -u [filesystem-username] -e

Fourth, I could never get the crontab to write to a log file outside of httpdocs (I tried statistics/logs/cron_log every way I could think of... lol... no dice). I ended up just adding the MAILTO directive at the top of the crontab file during testing:

eg:

[email protected]
##      *       *       *       *       *       php -q httpdocs/cron.php
小忆控 2024-08-19 13:42:17

如果您有 Plesk 10 或更高版本,另请参阅此内容:http ://shaun.net/2011/09/solving-plesk-10-3-1-cron-issues/

我必须这样做

/usr/local/psa/bin/server_pref -u -crontab-secure -shell "/bin/sh"

使其(示例)正常工作: wget -O - http://www .yourdomain.com/cron.php

Also see this if you have Plesk 10 or above: http://shaun.net/2011/09/solving-plesk-10-3-1-cron-issues/

I had to do this

/usr/local/psa/bin/server_pref -u -crontab-secure-shell "/bin/sh"

to get this (example) working: wget -O - http://www.yourdomain.com/cron.php

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文