This topic is locked

Guide 73 - Batch Task Scheduler

10/26/2023 3:23:32 PM
PHPRunner Tips and Tricks
fhumanes author

img alt
As soon as you have an application with a minimum of complexity, you immediately identify that you need to execute tasks in the background or Batch, to execute processes at certain times, for example, information migration, backup of your system, etc.
If you have full access to your system, you immediately remember CRON or Crontab, which is the operating system's task scheduler.
You don't always have full access for this type of configuration and it is also complex. Additionally, you have the problem that transferring your application from one machine to another, you have to remember that there are actions outside your application, so it is a possible source of problems.
I have designed a system that allows 100% integration with PHPrunner and that eliminates the problem of configuration migration, and facilitates the definition and management of these Batch tasks.
Objetive
Have a system, similar in Crontab functionality and fully integrated with PHPRUNNER.
This system must allow:

  • Define the tasks in forms made in PHPRunner, where you specify:


  • Initial date of execution of the Task.


  • Final execution date of the Task.


  • Execution interval, defined in months, days, hours and minutes.


  • Execution command with variable path depending on the location of the application.


  • Record for each execution indicating: start time, end time and result of the execution.


  • Definition of maximum execution time and if it is exceeded, cancellation of the process.


  • Single execution of a Batch task in the system (so as not to overload the system).


  • In Batch tasks, possibility of traces, for purification and control, integrated with the PHPRunner application.


  • Standardization of Batch tasks, to use the data base connection of the PHPRunner application (ease in migration between systems).



DEMO: https://fhumanes.com/scheduler/
(This version is limited to prevent misuse of examples)
img alt
Information that we process for each task. It is not executed when the “Status finished” field is checked or the “Date Next Execution” field is less than the current date.
Also, in the definition of the command to be executed there are these substitutions:
{DIR} .- It is replaced by the path where the application
{ID_TASK} is being executed.- It is replaced by the ID of the execution log record.
If you are interested in this topic, follow this link to see the full article.

milver 3/8/2024

share with us please :)