A
A
Atitr2019-07-07 12:52:09
Drupal
Atitr, 2019-07-07 12:52:09

How to implement periodically called Drupal 8 module?

Some module functions must be executed at a certain time (once a day).
It is planned to use the Linux system service - Cron to periodically run functions.
As an option, call the page of the module, the controller of which will execute the code.
But here the question arises: how to restrict access to this page?
How do I make it clear to the called (Cron task) page that it is being accessed by an authorized user?
Is the approach described above correct or does the solution look different?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
andead, 2019-07-07
@andead

how to restrict access to this page?

Add a private key to the address

A
afi13, 2019-07-07
@afi13

Drupal has its own cron tools. You can use hook_cron() and the Ultimate Cron module
https://www.drupal.org/docs/8/cron-automated-tasks...
https://www.drupal.org/docs/user_guide/en/security. ..
https://api.drupal.org/api/drupal/core!core.api.ph...
https://www.drupal.org/project/ultimate_cron

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question