Supervisor is a background job/task management tool that can handle running processes on your UNIX systems. You can view the number of Supervisor jobs running on your server in your RunCloud dashboard.
The Difference Between Supervisor and Cron
Cron jobs are scheduled jobs that are executed at a given time or a specified frequency. They don’t care when the last execution of the job finished – or even if it finished.
For example, if you have a task that takes 7 minutes to execute, and you create a cron job to execute it every 5 minutes, then it will launch a second task even before the first one is complete. Similarly, if the task only took 3 minutes, then the system would sit idle until 5 minutes had passed.
This is a good choice for time-based tasks, such as WordPress Cron jobs, that need to be scheduled with a specified frequency. To disable wp-cron with a real cron job, refer to our guide on how to add cron jobs here.
A Supervisor job, on the other hand, is much more efficient and directly communicates with the kernel. If your script has interrupts, such as waiting for input, then you should run it using supervisord. These scripts are always running, and handle interruptions much more gracefully. If you’re using Artisan Queues with Larvel, then you should use a Supervisor job instead.
Creating A New Job
To add a job, head to your RunCloud dashboard and click on the “Supervisor” button in the side menu.
On the next screen, provide a descriptive name for the job and configure other basic settings.
In the ‘Vendor Binary‘ section, you need to specify which version of PHP (or node) you want to use for executing the script.
After this, you need to provide the command that you want to execute. You can optionally provide the path to the folder and any additional config that you want.
Once you have configured the settings, click on “Save Supervisor Job” to add this job to your server.