Code Monkey home page Code Monkey logo

Comments (5)

liebig avatar liebig commented on July 16, 2024

Hi Amirkheirabadi, thanks for using cron. Which function is only exectued once? Do you call the Cron route manually? Which operation system is running with Cron? Maybe there is a problem with the overlapping feature. On some Windows systems the lock file could not be deleted. Please have a look in your app/storage/ directory if there is a cron.lock file and please delete it. Use the 'Cron::setDisablePreventOverlapping();' method call to disable the overlapping function. I hope this helps.

from cron.

amirkheirabadi73 avatar amirkheirabadi73 commented on July 16, 2024

hi liebig ... thanks for reply ...
i am use mint ...
for example :

Route::get('/cron/run/c68pd2s4e363221a3064e8807da20s1sf', function () {
    Cron::add('example1', '* * * * *', function() {
                        // Do some thing
                        return null;
                    });
    $report = Cron::run();
    print_r ($report);
});

when i past this code ... function :

function() {
                        // Do some thing
                        return null;
                    }

only once execute . but i need to execute this function every 1 min for example ..
thanks

from cron.

liebig avatar liebig commented on July 16, 2024

Hi amirkheirabadi, okay I understand the problem. A PHP application only runs when you call it (for example via request). Laravel and Cron will be loaded then, executed and after returning the response the application will be termined. It is not possible to run a PHP application over hourse like a Tomcat Server do. So you need something which call the route "/cron/run/c68pd2s4e363221a3064e8807da20s1s" every minute. Cron only checks, if it is executed, which jobs have to be run and which jobs not. So if you only have one job for every minute, you don't need Cron. You can easily do all the business logic in this route without Cron. But if you have a job for every minute, two jobs for every 15 minutes and so on, Cron can help you.

"Now we have to ensure that this route is called in an interval. This can be done with renting an own (virtual) server or with an online cronjob service. In both cases Google knows many good providers. An online cronjob service overview can be found at http://www.cronjobservices.com/"

Now your server or an online cronjob service will call the Cron route for example every minute, Cron will check which jobs need to be exectued (for example the every minute jobs '* * * * *') and will log the return values. But you always need something which call Cron, because if Cron is not running it is sleeping.

from cron.

amirkheirabadi73 avatar amirkheirabadi73 commented on July 16, 2024

oh ... thanks ... this is good idea ...
for last question . i now use crontab in app for schedule . you know way to i able to manage this with code in laravel ?

from cron.

liebig avatar liebig commented on July 16, 2024

Unfortunately it is not easily possible to manage crontab with PHP. You need SSH access to the server. You can find a guide here: http://code.tutsplus.com/tutorials/managing-cron-jobs-with-php--net-19428

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.