How can I implement a background "Timer" in PHP of my page that checks for something every time X

I want to implement something that makes every X-time some action. I want this worker thread to run on my server (PHP).

For example:

I have a blog and I want someone to handle comments with the "XXXX" keyword. I want this process to be able to sleep every X minutes, and when it wakes up, type, it is going to delete comments.

I don't want a solution, I only want how to implement this type of process in a PHP server (Apache).


source to share

1 answer

You can use a cron job to run a PHP script every x minutes, etc.

All you have to do is make a PHP file to do what you need to do and then tell cron to the PHP file and it will run anytime you specify

If you are using something like Plesk or cPanel, cronjobs are built in and very easy to use.



All Articles