Pages

Wednesday, August 10, 2011

Scheduling Crone Jobs from Console shells in Cakephp

I wrote a scheduler and then used the file given at
http://book.cakephp.org/view/1110/Running-Shells-as-cronjobs
to run the same as crone jobs but it wasn't that easy to proceed.

Usually webspace providers provide services to schedule crone jobs and get their output via mail from their control panel.Since my service provider provides service from a linux server so following tutorial is tried and tested on linux server however I will be glad if someone pastes their experience with windows machines as well...

So lets start from beginning I will discuss the errors faced as we proceed

1) I created a file cakeshell and copied it to vendors folder in root when I tried to run my shell I got following errors

/bin/bash^M: interpreter:No such file or directory
Solution:Remove the commented line at the top of the file cakeshell i.e

#! /bin/bash

2) Generally web space providers add php path to the system path already so in those cases we do not need -cli /usr/bin to add as parameter as given in the link however if it is not added you will need to add it.

If you are unable to find the path i.e you are getting error msg such as file not found make sure you are starting from root

Mine was as follows

/home/username/public_html/app name/vendors/cakeshell
-console /home/username/public_html/app name/app/console
-app /home/username/public_html/app name/app
-cli /usr/bin (if your php path is not added to system path else not required)

3)Make sure cakeshell and cake(in console) have permissions to execute for all

That's all create a shell and add a crone job to your scheduler on server and it will run

No comments:

Post a Comment