Organizational Research By

Surprising Reserch Topic

how to execute php code periodically in an automatic way

how to execute php code periodically in an automatic way  using -'php,mysql,scheduled-tasks'

I am willing to truncate a table in a MySQL database periodically but I don't know how to make the code that does so run in a specific period of time automatically e.g every week. Do you know any approach or class to do so?

EDIT: I am on windows sever

asked Oct 13, 2015 by amit.gupta
0 votes
1 view

Related Hot Questions

1 Answer

0 votes

You have two approaches.

First is based on cron jobs - your system may automatically call some PHP script every week. See more in Wikipedia article and learn Cron based on examples (I have seen also some interesting tool somewhere on GitHub, but I am unable to find it at the moment).

The second is to call some task during execution of different script, eg. when you do not have access to crontab. You may eg. store information about executed scripts in the database - if 7 days have passed after last execution, then execute some function / script and save the new timestamp into the database.


You said you are on Windows, but there are cron-like solutions also.

To add scheduled tasks, follow the guidelines from article on

You can also run Cron-like software, eg. CRONw - Cron for Windows.

answered Oct 13, 2015 by sumit_jaiswalmca