This is part of troubleshooting why my Cron job set up via CPanel to run a Cakephp shell, isn't working.
This is what I initially did, after reading http://book.cakephp.org/2.0/en/console-and-shells.html I created via CPanel cronjob that runs every 1 minute the following command:
php /home4/theadvop/public_html/app/Console/Cake test
By right I'm expecting it to execute TestShell.php (stored in Console/Command). This TestShell.php is a class that extends Appshell, and has a main() function that sends a test email in php code.
All of the above didn't work, no emails were sent, and no error logs were produced anywhere. So i decided to manually test things via SSH as shown below, which also strangely, shows no output.
Via SSH I've browsed to my app directory and tried running Console/cake, I get permission error.
So I did a chmod as shown in the attachment.
Now I tried running Console/cake from the app folder. But no output and nothing happens. Eventually I have to Ctrl-C my way out of it.
I then try to run Console/cake using my php file as a parameter (my php file is called TestShell.php in the Console/Command folder. Again nothing happens.
Any idea whats wrong with my setup?
Edited below to include email output.
Note I have changed my Console/Command/TestShell.php to output a line simply like this. It no longer attempts to send an email (to keep things simple)
echo "This is an output from testshell";
My Cron Job when running this:
php /home4/theadvop/public_html/app/Console/Cake test
Will result in the Cron sending me email that looks like this:
Content-type: text/html
################################################################################
#
# 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)
#
# Licensed under The MIT License
# For full copyright and license information, please see the LICENSE.txt
# Redistributions of files must retain the above copyright notice.
#
# @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
# @link http://cakephp.org CakePHP(tm) Project
# @package app.Console
# @since CakePHP(tm) v 1.2.0.5012
# @license http://www.opensource.org/licenses/mit-license.php MIT License
#
################################################################################
# Canonicalize by following every symlink of the given name recursively
canonicalize() {
NAME="$1"
if [ -f "$NAME" ]
then
DIR=$(dirname -- "$NAME")
NAME=$(cd -P "$DIR" && pwd -P)/$(basename -- "$NAME")
fi
while [ -h "$NAME" ]; do
DIR=$(dirname -- "$NAME")
SYM=$(readlink "$NAME")
NAME=$(cd "$DIR" && cd $(dirname -- "$SYM") && pwd)/$(basename -- "$SYM")
done
echo "$NAME"
}
CONSOLE=$(dirname -- "$(canonicalize "$0")")
APP=$(dirname "$CONSOLE")
exec php -q "$CONSOLE"/cake.php -working "$APP" "$@"
exit
Did not understand the above but i think Cron was executing the wrong thing because the output seemed to be about "baking".
After that I tried to remove the "php" of the cron job command so the cron runs this:
/home4/theadvop/public_html/app/Console/Cake test
The Cron then sends me the following email:
/home4/theadvop/public_html/app/Console/cake: fork: retry: Resource temporarily unavailable
/home4/theadvop/public_html/app/Console/cake: fork: retry: Resource temporarily unavailable
/home4/theadvop/public_html/app/Console/cake: fork: retry: Resource temporarily unavailable
/home4/theadvop/public_html/app/Console/cake: fork: retry: Resource temporarily unavailable
/home4/theadvop/public_html/app/Console/cake: fork: Resource temporarily unavailable
No input file specified.
I still have no idea what i'm doing wrong.