Cron Jobs or PHP Scheduler

Better way to schedule cron jobs based on job orders from php script

While it is possible to use the database as a queue, it is commonly known as an anti-pattern (next to using the database for logging), and as you are looking for:

So any way / package / system to accomplish this behavior?

I use the free-form of your question thanks to the placed bounty to suggest: Beanstalk.

Beanstalk is a simple, fast work queue.

Its interface is generic, but was originally designed for reducing the latency of page views in high-volume web applications by running time-consuming tasks asynchronously.

It has client libraries in the languages you mention in your question (and many more), is easy to develop with and to run in production.

Can I modify the schedule of a cron job from a php script that it is being executed by another cron job?

Make sure you do not break something you better monitor your cronjobs after you deploy this But what you want to do is possible.

  1. You can create, modify and delete Cronjobs via PHP (Use PHP to create, edit and delete crontab jobs?)

  2. This is also true if this PHP is executed via another cronjob (as long as you give the correct permissions)

⇒ It is possible (q.e.d.)

Also see this question: https://askubuntu.com/questions/408611/how-to-remove-or-delete-single-cron-job-using-linux-command

This is how you remove a single cronjob (by example) - just create a new one for the different dates:

crontab -u mobman -l | grep -v 'perl /home/mobman/test.pl'  | crontab -u mobman -

Running a cronjob with Laravel 5.6 (using the Scheduler)

You're using xamp, so I assume you're on windows. I suggest you download and install https://sourceforge.net/projects/cronw/
Then you can use unix style cronjobs to run your jobs.

You can also look into using the windows task scheduler, but using the cron scheduler works better in my opinion because the windows task scheduler only allows once per 5 minute triggers.

You'll also need to follow the instructions in the INSTALL file to get cronw up and running. But once it runs it's very easy to manage just like unix crontab's

You run the Laravel scheduler every minute, but the Laravel scheduler then looks into what needs to be run in it's schedule.

You have Cron triggering your scheduler.

Then your scheduler loads it's jobs.

It iterates those and filters out that are not scheduled yet

Eglible scheduled jobs are executed.

Cron is just a way to kick the scheduler to see if there are any pending jobs eglible to be run.

If you just wish to run artisan commands and not use the scheduler service you don't need to run every minute, but you can let the cron job run every 10 minutes.

Personally i'd advice a scheduler job to be run, since you can then have it not execute if the previous process hasn't finished yet, stopping two processes executing simultaneously.

The >> /dev/null 2>&1 is as posted in the link https://unix.stackexchange.com/questions/163352/what-does-dev-null-21-mean-in-this-article-of-crontab-basics as a comment by rkj a simple way to prevent an automatic email to be sent to you as a status report.



Related Topics



Leave a reply



Submit