How to schedule time-based (Cron) tasks using PHP? [closed]

0

I'm developing a module in prestashop, and I need to schedule some tasks based on time. For example: On X run the Y function of my module.

Is there a way to interact with the prestashhop cronjob module? Is there another solution for this? I'm thinking about PHP, a solution in javascript would also be valid.

    
asked by anonymous 24.11.2016 / 15:21

1 answer

1

So PHP is a language that collects and processes the data and provides a result, so it does not have native cron functions and should not even try to mock it for it to have it. (That is, it processes the data that it has to process and it dies soon after)

Well, now your operating system is different, it can create check a file regularly (crontab) and execute certain statement as specified.

Exemplifying:

# [Quando vai rodar] [Comando que vai rodar]
  * 1 * * * php      /var/www/site/public/index.php --module=z --action=y

That is, I specified that the command "/var/www/site/public/index.php --module = z --action = y" will run every day at 1 o'clock.

Anyway, configuration may change depending on the operating system, so I recommend that you learn the concept ( link ) of a cron, and apply according to your system.

    
24.11.2016 / 17:02