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@gmail.com");
}
}
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
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.