Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3425140
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:33:31+00:00 2026-05-18T06:33:31+00:00

I have a CakePHP script that should hopefully be run by a cron job.

  • 0

I have a CakePHP script that should hopefully be run by a cron job. It runs fine from the command line, but seemingly not from the cron. The cron line is something like:

*/2 * * * * cd /path/to/app;../cake/console/cake do_update

The script itself – and this is the bit that I think may possibly be too wacky, to the extent of throwing off the cron – loops through a subset of a Realtors table in the database, using the system time to decide which 50-record slice of the database to update:

$realtors = $this->Realtor->find('all',array(
'conditions'=>array('Realtor.zone_id'=>1),
'order'=>array('Realtor.num DESC'),
'limit'=>50,
'offset'=>date("i")*25
));

So my question(s) is/are – is there anything I’m doing here that would obviously throw the cron job for a loop? And, perhaps more importantly, is my method of splitting a database into manageable chunks over the course of an hour crazy? (I’m pretty much a programming newbie, so I try a lot of things without knowing whether they’re good practice or not.) Can anyone suggest a better way of looping through and updating large numbers of database records via a cron, that prevents the individual queries from being too huge for the system to handle?

EDIT: not only does it always work from the command line, it also works when run by cron script on a different server. I guess there’s just something messed up on the particular server, so it seems doubtful there’s a code-related solution! I’ll just accept an answer from among the useful cron-related insights below…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T06:33:31+00:00Added an answer on May 18, 2026 at 6:33 am

    Generally, you’d want to put all your command line stuff into an shell file

    /path/to/cake/console/cron.sh

    #!/bin/sh
    cd /path/to/app
    php ../cake/console/cake do_update
    
    */2 * * * * sh /path/to/cake/cron.sh
    

    Normally I don’t care about where the application actually starts (if i’m not using files) and just do

    */1 * * * * php /my/path/my_php.php
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a model in CakePHP that doesn't have a table, called Upload. I've
I have a CakePHP application that uses a number of vendor classes, including one
I have built a cakephp app that needs the user to login or register(for
I have a CakePHP 1.2 application. I'm running into the case where I need
I am working on development of an application using CakePHP framework. We all have
Does CakePHP have a form helper for html drop downs?
Have just started using Google Chrome , and noticed in parts of our site,
Have you ever seen any of there error messages? -- SQL Server 2000 Could
Have you guys had any experiences (positive or negative) by placing your source code/solution
Have just started using Visual Studio Professional's built-in unit testing features, which as I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.