Payments are experiencing issues due to temporary restrictions in Russia. If your payment does not go through, please submit a support request.Our support team is available 24/7 — we are always here to help with hosting and server issues.We are now accepting requests for dedicated server rental and colocation services in our data center.Reminder: we recommend enabling backups for additional data protection.A new VPS/VDS lineup with NVMe storage and improved performance is now available.Maintenance work on some servers has been completed. All services are operating normally.
Article6 min readViews9

1C-Bitrix Agents Run Late: Where to Find the Queue

The next run time has arrived, but the result appeared later. We examine three distinct stages separately: who triggers the agent check, when the agent receives the queue, and how long its own execution takes.

Comments 0

Albina reviews the background task queue and the selected item on the timeline.
In this article

In the agents list, the next run time is already in the past, cron has triggered, yet the email, export, or recalculation still appears late. It is tempting to blame cron. However, it may be running faithfully every minute and not be responsible for what happens afterward.

To avoid fixing the schedule blindly, I divide the delay into three stages: the trigger for the agent check, the selection of the task whose deadline has arrived, and the execution of the function itself. Each stage requires its own timestamp. Otherwise, two different problems look identical: "the agent was late."

Next run time is not a promise of an exact second

The next run time field means the agent can be selected for execution after that moment. However, the check code must be invoked: either during page processing or by a separate scheduled process if the system uses cron. Therefore, the actual start cannot occur before the next invocation and may happen later due to the queue.

Official documentation for the main module describes agent checks as the execution of functions whose scheduled time has arrived. In visit-based mode, such checks are tied to the start of page processing. On a low-traffic site, this immediately creates a clear boundary: without a suitable visit, there is no precise minute-level rhythm.

Moving to cron removes the dependency on traffic, but it does not turn the schedule into a separate executor for each agent. One invocation must still receive the list of tasks and perform the work in an available process.

The timeline shows the agent's schedule, the next check call, the wait in the queue, and the actual result.
The schedule makes an agent available for execution. The actual result appears after the check is called, the wait occurs, and the function runs.

Periodic and non-periodic agents calculate the next date differently.

For a periodic agent, the next date is tied to the previous scheduled run and the interval. For a non-periodic agent, it is tied to the moment of successful completion and the interval. This difference is important during investigation: long-running tasks may appear differently in the history and affect the timing of the next execution.

A non-periodic scheme is convenient when a new launch cannot overlap with an unfinished previous one. However, it also means the interval starts only after the work ends. If the function took twenty minutes, waiting for the next result five minutes after the original deadline is incorrect.

Periodicity alone does not indicate whether a task completes, whether it repeats the same data batch, or whether it safely survives an error. These properties are defined by the function logic, not the schedule string.

First, prove that the check is being called

The first pair of times is the planned cron moment and the actual process start. These are taken from the scheduler log and the handler's own startup log. A successful cron status without an internal marker in the handler proves only an attempt to run the environment command, not the execution of the required application path.

  • Are there regular process starts in the expected time zone?
  • Does the process reach the agent check instead of terminating early?
  • Are the environment, user, and access to the required configuration identical?
  • Is another mechanism not running simultaneously that changes the picture?

In this article, I intentionally do not provide a universal cron string. The project path, environment version, deployment method, and agent configuration settings differ. A copy-pasted command without these conditions more often adds a second launch than it explains the first.

Then separate the queue from the function itself

If the check is triggered on time, compare the handler entry moment with the specific agent start moment. A large gap between them indicates a queue or work performed before the required agent. A small gap with a late result shifts focus to inside the function itself.

The diagnostic scheme separates cron startup, agent checks, waiting for a specific task, and its business result.
Four timestamps allow distinguishing a call failure from a queue and the agent's own prolonged work.

The minimal observation set includes the run identifier, agent name or ID, start and end times, result, number of processed items, and the timestamp of the last successful step. Operational data and secrets are not logged. If a task processes in batches, recording batch boundaries is useful so that a retry does not appear as a new success.

A long-running agent may occupy the process with network activity, an external API call, a large query, or processing an excessively large batch. Even when the server has sufficient CPU, waiting for an external system leaves subsequent tasks without a start. Therefore, a graph of overall load is useful but does not replace the duration of each segment.

Do not confuse agent startup with business result

The agent could have started on time and passed the work to a separate queue. In this case, the agent completion marker indicates only that the task was successfully queued, not that an email was sent or that the stock level was updated. A single identifier that travels from the agent to the queue consumer and the final event is required for such a scenario.

The reverse situation also occurs: the business result is created, but the interface displays an old state from the cache. If you check only the screen, execution delay mixes with display delay. First, search for the event in the result source, then trace the path to the interface.

Four timestamps provide a working diagnosis

  • T1 — the moment the agent became available for execution.
  • T2 — the actual call to the agent check mechanism.
  • T3 — the start of the specific agent function.
  • T4 — the confirmed business result or handover to the next queue.

The difference T2 − T1 shows the call delay. T3 − T2 represents the wait time within the execution mechanism. T4 − T3 indicates the function duration and subsequent synchronous steps. If a separate queue exists after the agent, add another result marker for its consumer. This is a training model, but it forces a more precise problem formulation than "cron is slow".

It is better to measure several sequential runs, including both normal and elevated load. A single successful run does not rule out a queue, and a single failure might coincide with maintenance of an external service. At the same time, monitoring must not itself generate heavy requests or expose order contents.

When to change the schedule versus when to change the function

Change the schedule if it is proven that the check is called less frequently than required or runs in the wrong environment. Address the queue if the call is regular but T3 lags significantly behind T2. Optimize the function or split it into chunks if the main time is spent between T3 and the result.

Before making changes, it is useful to define the acceptable delay for a specific process. Sending a service report can wait, but removing unavailable items from sale carries a different risk. Having the same minute in the schedule does not make these tasks equally urgent.

If an agent runs late, a good outcome of the investigation is not a new cron line, but the identified delay segment and the verifiable stop condition. The call must be regular, the queue must be observable, the function must fit within its window, and the business result must be confirmed separately. Then the next delay will be visible by time and location, not by a random complaint.

Discussion 0

Share your experience and ask questions. Comments without links appear after editorial review.

No comments yet. Start the discussion.