Cakephp Shell Cronjob 控制器 Action Media Temple 服务器

发布于 2024-08-11 14:26:56 字数 1189 浏览 3 评论 0原文

我正在尝试创建一个 cron 作业来发送每周的新闻通讯。我尝试按照 Cakephp 手册 的说明创建 shell 任务。然后我转到 Media Temple Cron 作业并输入以下内容:

php /home/#####/domains/domain.com/html/cake/console/cake -app /home//### ##//domains/domain.com/html/vendors/shells newsletter

我在vendors/shell文件夹中创建了shell任务并将其命名为newsletter.php,这是它的代码:

class NewsletterShell extends Shell {

    function main() {

    $this->sendEmailTo("Newsletter","subject","[email protected]");


    }
}

sendEmailTo是一个控制器函数我在我的 appController 中,所以我的所有控制器都可以访问它。

我的问题是每次 Cron 作业运行时我都会收到此消息:

无法打开输入文件:/home/#####/domains/domain.com/html/cake/console/cake

我什至给出了所有控制台文件( cake.php 、 cake.bat 等)0777 读写属性以及vendors/shell/newsletter.php

##### 是媒体寺庙为您提供的站点编号,但我不确定我是否拥有它正确的。他们展示了一个像这样的 cron 作业的示例: /home/50838/data/script-name.sh

所以我的问题是:

我的 cake shell 任务是否正确以及我将其作为 cron 作业运行的方式是否准确?

还有人知道在哪里可以确认我的媒体寺庙站点编号,以便我可以将其作为可能的错误注销。

预先感谢,

法比安

I'm trying to create a cron job that will send a weekly newsletter. I tried creating a shell task following what Cakephp manual says. Then I go to the Media Temple Cron jobs and type in the following:

php /home/#####/domains/domain.com/html/cake/console/cake -app /home//#####//domains/domain.com/html/vendors/shells newsletter

I created the shell task on vendors/shell folder and named it newsletter.php and here's the code for it:

class NewsletterShell extends Shell {

    function main() {

    $this->sendEmailTo("Newsletter","subject","[email protected]");


    }
}

The sendEmailTo is a controller function I have in my appController so all my controller have access to it.

My problem is every time the Cron Job runs I get this message:

Could not open input file: /home/#####/domains/domain.com/html/cake/console/cake

I even gave all the console files (cake.php , cake.bat etc) 0777 read write properties as well as for the vendors/shell/newsletter.php

The ##### are the site number that media temple gives you but I'm not really sure I have it correct. They show an example of a cron job like this: /home/50838/data/script-name.sh

So my questions are:

Is my cake shell task correct and is the way I'm running it as a cron job accurate?

Also does anyone know where to confirm my media temple site number so I can write that off as a possible error.

Thanks in advance,

Fabian

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

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

发布评论

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

评论(3

Hello爱情风 2024-08-18 14:26:56

您可以尝试 var_dump(ROOT) 或任何其他 核心定义常量来查找您的目录。只需将其放在控制器方法中的某个位置,但请确保再次将其删除。或者,如果您有 SSH 访问权限,请在命令行上执行 pwd

除此之外,当调用 cake 控制台任务时,-app 参数应该指向 app 目录,而不是 shell 目录。


尝试使用 此脚本 将 shell 作为 cron 作业运行,可能缺少一些 shell 变量。

You can try to var_dump(ROOT) or any one of the other Core Definition Constants to find your directory. Just put it in a controller method somewhere, but make sure to remove it again. Or, if you have SSH access, do pwd on the command line.

Other than that, when invoking the cake console task, the -app parameter is supposed to point to the app directory, not the shells directory.


Try to use this script to run your shell as cron job, there may be some missing shell vars.

尤怨 2024-08-18 14:26:56
ls -l /home/#####/domains/domain.com/html/cake/console/cake

说什么? cron 作业是否以用户 ##### 运行?如果没有,问题可能是 /home/#####/ 上的权限,请检查它们

ls -ld /home/#####/
ls -l /home/#####/domains/domain.com/html/cake/console/cake

says what? does the cron job run as user #####? if not, the problem is probably permissions on /home/#####/, check them with

ls -ld /home/#####/
蓝戈者 2024-08-18 14:26:56

您是否已授予“cake/console”目录中的“cake”文件以及cake.php和cake.bat可执行权限?

cron 命令应该是:

php /home/#####/domains/domain.com/html/cake/console/cake newsletter -app /home/#####/domains/domain.com/html/app

Have you given the "cake" file in "cake/console" directory executable permissions as well as cake.php and cake.bat?

The cron command should be:

php /home/#####/domains/domain.com/html/cake/console/cake newsletter -app /home/#####/domains/domain.com/html/app

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