views:

582

answers:

2

I'm using the CakePHP Console to download files from we and processed in a database. I'm running the console from inside the "app" directory. But when I'm trying to run the console outside app and by just setting the "-app" parameter for my cron job, it doesn't work.

To be honest, I've had no success using -app parameter. It's like it's not working at all.

By the way, I'm using Windows & Pycron for my cron jobs.

Here's what happens when I'm trying to run the console from D:\

D:\>web\elink\cake\console\cake -app D:\web\elink\app


Welcome to CakePHP v1.2.2.8120 Console
---------------------------------------------------------------
Current Paths:
 -app: app
 -working: D: -app D:/web/elink/app
 -root: D: -app D:/web/elink
 -core: D:\web\elink

Changing Paths:
your working path should be the same as your application path
to change your path use the '-app' param.
Example: -app relative/path/to/myapp or -app /absolute/path/to/myapp

Available Shells:

 D:\web\elink\vendors\shells:
         - none

 CORE\console\libs:
         acl
         api
         bake
         console
         i18n
         schema
         testsuite

To run a command, type 'cake shell_name [args]'
To get help on a specific command, type 'cake shell_name help'

My shells are located at D:\web\elink\app\vendors\shells.

+1  A: 

I have managed to reproduce this issue using versions 1.2.2.8120 and 1.2.3.8166 on Windows. The -app parameter doesn't seem to work at all as expected.

The console will only list global shells in the /vendors/shells folder and not application-specific ones located in /app/vendors/shells or in plugins (/app/plugins/plugin_name/vendors/shells).

The -app parameter works as expected on OpenSUSE, listing all available application-specific shells (including those in plugins).

Unless we are doing something incorrectly, it is probably worth opening a ticket on Trac about this issue.

A workaround would be to add your Cake console directory to the Windows PATH environment variable.

  1. Open 'System Properties' (Start key + Pause/Break key)
  2. Open 'Advanced' tab
  3. Click 'Environment Variables'
  4. Select the PATH variable in the 'System variables' section
  5. Press 'Edit'
  6. Append ;E:\web\elink\cake\console\ to the 'Variable value'
  7. Press 'Okay' on all dialogs
  8. Close all open cmd prompts

You can then set up pycron to run E:\web\elink\cake without the -app parameter and all your application-specific shells should be available.

deizel
I've done this but when I type cake, the application-specific shells still don't show up. However, this time the -app parameter works as expected. Thanks deizel.
Gian Basagre
+1  A: 

-For the people having the same problem but on linux systems, here there is an easy solution:

http://book.cakephp.org/complete/3/The-Manual#Running-Shells-as-cronjobs-846

-Another alternative solution for any system would be to create a simple script with two lines like this:

cd /path/to/app
/path/to/cake

-Both solutions worked for me in a Cent0S and in a MacOS based machines.

Héctor García