Job scheduling and publishing

Asked

Viewed 236 times

0

good afternoon!

I’m trying to build a publishing scheduling system. I have a table where are stored the date/time that the post should be published, when the scheduled date is equal to the current date, I want an action to be executed called the Facebook API and passing the post data.

Where should I put this action, inside the job in sql?

I’m lost in how to do this.

What other ways would you use?

  • Do you have a table with the times of publication, ? in this table has the condition to verify if it has already been published ? knows the Scheduler of Laravel ?

  • @Bulfaitelo the table has the times of publication and validation. I’m still studying the Standard did not know the Scheduler

  • I will try to answer in a way that mounts an environment that you can use, so you can have the basis to set up this schedule, ta bom

  • Okay, thank you very much! I will start reading about the Scheduler of Laravel also

3 answers

0

You will need to define a Schedule of Laravel, it is very simple to use and configure, just follow the documentation that will not have any problem. but I will leave an example for you:

It stays inside of App\Console\Kernel.php;

protected function schedule(Schedule $schedule)
    {
        $schedule->command('tesouro:extrato')            
       ->weekdays()
       ->hourly()
       ->between('10:00', '13:00');
    }

In this example I am running the command tesouro:extratoall the weekdays every 1 hour from 10 am to 13 pm.

Now to your case,

What you can do, create a method that when called it checks the current system time and compares with the time of the posting table, if current time is longer than the posting hours and the posted status is still fake, it sends these results, the logic to do this and simple.

It would only be to search, the records not yet published based on the current time, go through them and publish, at the time it is published update the record table so that that post is marked as published.

Set the recurrence that wants to execute this method and ready, (here would enter the Schedule)

I recommend starting with the posting method, as you are still learning, focus on the most laborious part, so at last you do the Schedule.

I hope to give you at least a basis for how to proceed.

-2

I do not know much but you may be using CRONTAB to schedule execution of php scripts, this in linux it is as if it were windows services.

-2

You can work with cron, just every time you generate a new scheduling, vc generates a new cron file, this same one will make a request for somewhere in your system at the expected time, and in it you do well understand.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.