1

I have tried and browsed a lot regarding how to set cron job with CakePHP and zpanel

In zpanel I tried different types url

For example

  1. domain_folder/app/cron_dispatcher.php /CampaignMasters/newsletter_find_cron(Error: script does not exist)

Then I tried a file domain_folder/app/cronjob.php(Worked)

it worked but I am confused how can I call "domain_folder/app/cron_dispatcher.php /CampaignMasters/newsletter_find_cron" from cronjob.php

I am in a really twisted state, I have tried this for about 10 hours by trying many methods.

Any zpanel or CakePHP expert please just tell me the best way to set this as a cron job.

Can I add cron job through ssh in zpanel? If I can add this one through ssh "domain_folder/app/cron_dispatcher.php /CampaignMasters/newsletter_find_cron" Then it would be great. I am ready to try anything.

The OS is CentOS

user2742122
  • 603
  • 2
  • 8
  • 15

1 Answers1

2

I decided to go all out :)

Step 1

Create a shell class so that you can call the actions from command line.

http://book.cakephp.org/2.0/en/console-and-shells.html

class HelloShell extends AppShell {
    public function main() {
        $this->out('Hello world.');
    }
}

Step 2

Try the command that you've just created via SSH or terminal:

Console/cake hello

You may have to run this command in your app directory:

cd yourapp/app
../Console/cake hello

Step 3

Create a cron job using cron tab

crontab -e

Vim or your default text editor will open. Apply your cron command there.

* 00 * * 6 php your_app_path/lib/Cake/Console/cake.php hello

Checkout http://en.wikipedia.org/wiki/Cron to understand how occurrences work.

Save and done!

Timber
  • 859
  • 9
  • 25