How to run the PHP script at scheduled time

后端 未结 4 887
梦谈多话
梦谈多话 2020-11-30 15:17

I need to run a php script at the scheduled time daily to update some fields in database and to send automated email. How I can do this?

Is it possible to write so

4条回答
  •  自闭症患者
    2020-11-30 16:00

    PHP cannot run script by itself,since php doesn't have daemons like python !! So you have to take OS help to invoke your custom script .

    For example in linux : (example.sh) export USE_PHP=php cd $SCRIPT_ROOTDIR $USE_PHP -f cronfile.php service="checkdatabase" (service is the parameter passed to your cronfile).

    For setting up cron jobs ,have a look at this link http://www.cyberciti.biz/faq/how-do-i-add-jobs-to-cron-under-linux-or-unix-oses/

提交回复
热议问题