Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Supervisor VS CronJobs

I have to run a laravel command php artisan queue:work --daemon to run jobs stored on Beanstalkd queues.

I have come across two possible solutions:

  • Run commands using Supervisord: Register a command in the config files of Supervisord and start it.
  • Run commands using CronJobs: */1 * * * * /usr/bin/php /var/www/laravelProj/artisan queue:work --daemon --tries=3

Can someone please explain what way should I go and what would be the best for performance enhancement.

like image 893
MKJ Avatar asked Sep 10 '16 05:09

MKJ


People also ask

What is difference between scheduler and cron job?

Cron allows you to create your own chains manually. Scheduler allows you to place resource control (CPU limits, undo tablespace limits, etc) against your job. It allows you to define classes with priorities and assign jobs to those classes.

What is the difference between Cronjob and crontab?

Crontabs are the configuration files used by Cron to run services. Crontabs hold the configurations for which service to run and when it should run. Services are nothing more than an execution path to a script or application with possible additional commands. Cronjobs are the individual entries in that Crontab file.

Is Cronjob heavy?

Using a cron job to hit a web page to trigger application processes is not heavy. It is a bit of a long winded approach but the act of fetching the page itelf ( wget etc) is not heavy. The heaviness of your application process is another matter entirely of course.

What replaced cron?

By Florian Leibert, Harry Shoff, & Andy Kramolisch. Chronos is our replacement for cron. It is a distributed and fault-tolerant scheduler which runs on top of Mesos. It's a framework and supports custom mesos executors as well as the default command executor.


1 Answers

There is one main advantage of Supervisor that the task you set there is working constantly. This mean that when the proces will finish the new one will starts immediately.

Crontab runs every process for a minutue minimum! So if you have a task like queue:work is much better to use Supervisor over Crontab.

like image 87
Filip Koblański Avatar answered Sep 25 '22 06:09

Filip Koblański