Resetting a MySQL Field value without user execution

后端 未结 4 677
庸人自扰
庸人自扰 2021-01-28 14:10

I need to reset a MySQL Field value automatically at midnight. It is a specific column in a specific row in a table. I know how to do this in PHP but I do not know how to execut

4条回答
  •  长情又很酷
    2021-01-28 14:39

    If you are running on linux you would use a cronjob

    On most distros there is a command called crontab that schedules tasks for you and a specific format you need:

    0 0 * * * php /path/to/file.php
    

    EDIT: Wrote this before you edited yours :p I'm not sure there is any other way. Do you have a specific reason not to use a cronjob?

    You may not even need to specify the php part if the php file is marked as executable i.e

    0 0 * * * /path/to/file.php
    

    Just do "chmod +x /path/to/file.php" form the linux command line

提交回复
热议问题