CakePHP cron job problem in cPanel

There is a shell script in my project name with TxpPaymentShell.php

<?php namespace App\Shell; use Cake\Console\Shell; class TxpPaymentShell extends Shell { public function main() { $this->out('Test Cron'); } } ?>

This code is set cPanel cron job like

1 0 * * * cd /home/k12dev/public_html/ && bin/cake TxpPayment

but it’s not working even this same code is working properly when it’s run into Ubuntu Terminal with command prompt.

please help me

try to output everything to some log file i.e. add " >> /var/log/cron/worker.log 2>&1" at the end of cron job, its probably something like php not accessible globally or other silly thing just check the output and act accordingly

I get the help message as output

Welcome to CakePHP v3.0.0 Console

App : App
Path: /Users/markstory/Sites/cakephp-app/src/

Current Paths:

-app: src
-root: /Users/markstory/Sites/cakephp-app
-core: /Users/markstory/Sites/cakephp-app/vendor/cakephp/cakephp

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:

[Bake] bake

[Migrations] migrations

[CORE] i18n, orm_cache, plugin, routes, server

[app] behavior_time, console, orm

To run an app or core command, type cake shell_name [args]
To run a plugin command, type cake Plugin.shell_name [args]
To get help on a specific command, type cake shell_name --help

but if i run this from terminal it’s work perfectly

hm i dont see TxpPayment inside

also you are calling

/home/k12dev/public_html/bin/cake

but console reports as

/Users/markstory/Sites/cakephp-app/src/

sorry Graziel this is not the actual help message , it’s copy form the cakephp documentation. if you need i can upload that help message which i get. basically both help message are same type that why i just upload the cakephp documentation one.

yeah that would help, im using something like
*/10 * * * * /usr/bin/php71 /data/www/example.com/bin/cake.php Queue.Queue runworker >> /data/www/example.com/logs/worker.log 2>&1

and i dont have any problems with it so it has to be your setup you can try to add subcommand and check if its it cause i have never tried to use only ‘main’ function from shell with cron

Thank you @Graziel his is actuall help message which i get when the cron is set automatic. but when i run the cron manually i did not get any error.

Welcome to CakePHP v3.2.12 Console

App : src
Path: /home/k12dev/public_html/src/
PHP : 5.6.30

Current Paths:

  • app: src
  • root: /home/k12dev/public_html
  • core: /home/k12dev/public_html/vendor/cakephp/cakephp

Available Shells:

[DebugKit] benchmark, whitespace

[Migrations] migrations

[CORE] i18n, orm_cache, plugin, routes, server

[app] console, create_database, test, txp_payment

To run an app or core command, type cake shell_name [args]
To run a plugin command, type cake Plugin.shell_name [args]
To get help on a specific command, type cake shell_name --help

Content-type: text/html; charset=UTF-8

I think now you can understand the problem

same info when you try what console reports - txp_payment instead of TxpPayment ?

@Graziel i had tested with “txp_payment” but sorry to say same help code come, If you don’t mind could you please run my shell into your cpanel server.

<?php namespace App\Shell; use Cake\Console\Shell; class TxpPaymentShell extends Shell { public function main() { $this->out('Test Cron'); } } ?>

and also send me the command screenshot of cpanel as i send you earlier. I will really thank full for you if you do this.

sorry i dont use any admin panel, i ve access to shell and im just adding it to crontab

so could you please test my coding & tell me that command line with we will set into crontab

I mean here as i set the command you can see. what is the command line here???

This is why I don’t use cPanel anymore. Because even a simple task has long process. I prefer using platforms, like Cloudways PHP site hosting because they have made a lot of things easier. For example, for cron job, they have simple UI where you can upload the script and schedule your crons.