简体   繁体   English

如何在Amazon AWS(bitnami堆栈)上为cakephp网站配置cron作业?

[英]How to configure cron jobs for cakephp site on an Amazon AWS (bitnami stack)?

I want to execute a shell script in every minute. 我想每分钟执行一次shell脚本。 I used this command 我用这个命令

* * * * * cd /opt/bitnami/apache2/htdocs/sitename/app && Console/cake Sendnotification

Where Sendnotification is the shell name and sitename site folder name. 其中, Sendnotification是外壳程序名称和站点sitename站点文件夹名称。

Please let me know. 请告诉我。 I have been trying to fix this since from last 10 hours. 从最近10个小时开始,我一直在尝试解决此问题。

This is because PHP installed in non-standard path. 这是因为PHP安装在非标准路径中。 You will need to edit the Console/cake bake shell script to include the path to PHP executable. 您将需要编辑Console/cake bake shell脚本,以包括PHP可执行文件的路径。

Since you are using Bitnami , you can add the following line to the shell script: 由于您正在使用Bitnami ,因此可以将以下行添加到shell脚本中:

export PATH=/opt/bitnami/php/bin:$PATH

So your Console/cake file should look like this: 因此,您的控制台/蛋糕文件应如下所示:

#!/usr/bin/env bash
export PATH=/opt/bitnami/php/bin:$PATH

################################################################################
#
# Bake is a shell script for running CakePHP bake script
#
# CakePHP(tm) :  Rapid Development Framework (http://cakephp.org)
# Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)

...

(This works for me on CakePHP 2.x) (这在CakePHP 2.x上对我有效)

Bonus : You can edit your cron task to log the console output to a file for debugging: 奖励 :您可以编辑cron任务以将控制台输出记录到文件中进行调试:

* * * * * cd /opt/bitnami/apache2/htdocs/sitename/app && Console/cake Sendnotification  > /opt/bitnami/apache2/htdocs/sitename/logs/Sendnotification_`date +\%Y\%m\%d`-cron.log 2>&1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM