Question

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

Was it helpful?

Solution

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.

OTHER TIPS

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/#####/

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top