Home > other >  How to make Scheduler in php?
How to make Scheduler in php?

Time:02-03

I have Raspberry pi with installed Apache PHP. I would like to make PHP scheduler app, to allow users to control Air conditioner. When user creates time event, like "Turn on AC at 18:00", or "Turn on AC every weekend at 08:00" or "Turn AC off hourly", the php script must execute python script with specific parameters, like temperature, fan speed and etc.

So far I have made something similar, with php cron jobs/tabs but I don't think that this is good solution, because if I have lots of tasks, this may slow down the entire system.

CodePudding user response:

try to use systemd timers as is written here - a link

CodePudding user response:

From my experience with Raspberry Pi 4 2GB RAM, you may start to experience performance issues with more than a few hundred cron jobs.

For a small "smart home" project (around 60/70 cron jobs) I suggest you to use cron jobs in order to save time.

However, if you have a large number of tasks that need to be scheduled, as you mentioned, a task scheduler specifically designed for PHP, such as Celery or Gearman, would likely be a better choice than using cron jobs. These task schedulers allow you to run your Python script as a background task, so it won't slow down the rest of your system. Additionally, these task schedulers provide features for managing task queues and monitoring task execution, which can be helpful for managing a large number of tasks and ensure optimal performance.

  • Related