Git Product home page Git Product logo

Comments (13)

liebig avatar liebig commented on June 29, 2024

Which version of Laravel are you using? Did you installed Cron as described in the manual?

from cron.

tanmaysakhale24 avatar tanmaysakhale24 commented on June 29, 2024

Laravel Framework 5.5.2
Installed as same in the documentation. Cron::add function is working fine for me and records are getting updated in cron_job and cron_manager.
One more issue i have
I want to make the cron function (Basic insert query for testing like inserting 10000 records in table) timeout after 30 sec of execution time. But script continue to run for 48 sec successfully. I want to store the timeout error in cron_job.
I made changes in etc/php/7.0/cli/php.ini file by changing max_execution_time= 3 and changing max_input_time=3. But then also cron continue to complete its script, is there any way i can put a timeout limit to cron::add or any other options u have

from cron.

liebig avatar liebig commented on June 29, 2024

Maybe this can help: How do you set max execution time of PHP's CLI component?

from cron.

tanmaysakhale24 avatar tanmaysakhale24 commented on June 29, 2024

This helped me thanks. It is generating a fatal error and that error is not getting stored in cron_job table.

Help me with this issue too
After running php artisan cron:run
It shows
PHP Warning: Module 'pgsql' already loaded in Unknown on line 0
[ReflectionException]
Method Liebig\Cron\RunCommand::handle() does not exist

After running any command list,run and keygen. i got the same error.

Completed Following steps.
Installing Fresh Laravel

laravel new cronproject
php artisan key:generate
creating database
changing env file with the DB details
php artisan migrate
Add "liebig/cron": "dev-master" to your /path/to/laravel/composer.json file at the "require": section (Find more about composer at http://getcomposer.org/)
Run the composer update liebig/cron --no-dev command in your shell from your /path/to/laravel/ directory
Add 'Liebig\Cron\Laravel5ServiceProvider' to your 'providers' array in the /path/to/laravel/config/app.php file
Migrate the database with running the command php artisan migrate --path=vendor/liebig/cron/src/migrations
Publish the configuration file with running the command php artisan vendor:publish - now you find the Cron configuration file at /path/to/laravel/config/liebigCron.php and this file won't be overwritten at any update

I am calling the cron from controller
http://127.0.0.1:8000/cron

    Cron::add('CreateUser', '* * * * *', function() {
        $cnt=5000;
        $saved="";
        for($i=0;$i<=$cnt;$i++) {
            $user = new User;

            $user->name = "tanmay" . rand();
            $user->email = 'tanmay.sakhale' . rand() . '@gmail.com';
            $user->password = 'password';
            $saved = $user->save();
        }
        if(!$saved){
            return "Error:421";
        } else {
            return "Success";
        }
    });        
    $report = Cron::run();
    print_r ($report);
}

If i try it from AppServiceProvider by writing it on boot() function. How to call this cron automatically not having idea how to do this ??

Please help

from cron.

liebig avatar liebig commented on June 29, 2024

The Method Liebig\Cron\RunCommand::handle() does not exist error seems to be a namespace problem, because Liebig\Cron\Run does exist but Liebig\Cron\RunCommand does not. So please check your code! Please have a look at the README how to use Cron's integrated route also.

from cron.

tanmaysakhale24 avatar tanmaysakhale24 commented on June 29, 2024

image
This is showing when i am typing the command

from cron.

tanmaysakhale24 avatar tanmaysakhale24 commented on June 29, 2024

image
Now my cron started running by the run command. I checked it in the cron_job table.

Just i am not able to see list command. I am doing print_r to see the list of cron jobs.
How to solve this ReflectionException
Thanks for your help

from cron.

liebig avatar liebig commented on June 29, 2024

Can you please test to rename (in vendor directory) cron/src/Liebig/Cron/ListCommand.php line 37

public function fire() {

to

public function handle() {

and try the cron:list command again?
Thank you.

from cron.

tanmaysakhale24 avatar tanmaysakhale24 commented on June 29, 2024

It started working. Thank you for the help.

from cron.

liebig avatar liebig commented on June 29, 2024

Okay, then we have to change all the fire method names to handle for the command files. A PR would be awesome.

from cron.

liebig avatar liebig commented on June 29, 2024

I added a Pull Request for this issue.
@tanmaysakhale24 Please have a look at it and test it. You can download the laravel-5.5 branch and extract it to your vendor directory (or only the three command files KeygenCommand.php, ListCommand.php and RunCommand.php) and execute the commands. Thank you.

from cron.

liebig avatar liebig commented on June 29, 2024

I have tested the changes and they seem to work. PR is merged and closed.

from cron.

tanmaysakhale24 avatar tanmaysakhale24 commented on June 29, 2024

Ok I will try

from cron.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.