【发布时间】:2021-03-22 12:05:53
【问题描述】:
我正在尝试使用 Symfony 命令设置向用户发送电子邮件的 CRON 作业。 电子邮件部分有效。如果我在正确的目录中键入命令,我确实会收到我的电子邮件。
所以我想出了这个 CRON 命令: cd /home/c1583306c/public_html && php bin/console app:send-email:send
但是当命令执行时,Symfony 似乎无法识别我的命令,这是输出:
Symfony 5.2.3 (env: dev, debug: true)
Usage:
command [options] [arguments]
Options:
-h, --help Display help for the given command. When no command is given display help for the list command
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-e, --env=ENV The Environment name. [default: "dev"]
--no-debug Switches off debug mode.
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Available commands:
about Displays information about the current project
help Displays help for a command
list Lists commands
app
app:send-email:send My test command
assets
assets:install Installs bundles web assets under a public directory
cache
cache:clear Clears the cache
我做错了吗?
注意:我必须指定文件夹。否则,这将是输出:
状态:404 未找到 X-Powered-By: PHP/7.4.15 内容类型:text/html; charset=UTF-8
没有指定输入文件。
【问题讨论】:
-
请分享更多细节 - 您给出的内容看起来不像“cron 命令”,因为前面缺少
cd。另外,您尝试过什么调试问题? -
是的,很抱歉。光盘在这里,但它不工作
-
那么请分享有关您的调试尝试的更多详细信息
-
可以肯定的是,您的 cron 命令
cd /home/c1583306c/public_html && php bin/console app:send-email:send不起作用,对吧?如果您在 shell 中输入相同的内容会发生什么,例如当你 ssh 进入机器然后运行cd /home/c1583306c/public_html && php bin/console app:send-email:send?改用php /home/c1583306c/public_html/bin/console app:send-email:send怎么样? -
这听起来很奇怪——我还使用 cron 调用了一些 Symfony 命令,而且效果很好。请分享有关您的配置的更多详细信息 - 您是如何确切配置您的 crontab?