如何在计划的时间运行PHP脚本 [英] How to run the PHP script at scheduled time

查看:103
本文介绍了如何在计划的时间运行PHP脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在每天的预定时间运行php脚本,以更新数据库中的某些字段并发送自动电子邮件.我该怎么做?

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?

是否可以在XAMP服务器中编写一些服务以每天在计划的时间运行脚本?我不知道如何在计划的时间更新数据库并自动发送电子邮件.谁能分享一些想法或概念?

Is it possible to write some service in XAMP server to run the script daily at scheduled time? I have no idea how to update database and send email automatically at the scheduled time. Can any one share some ideas or concepts?

我正在使用在Linux Server中运行的PHP和MySQL.

I am using PHP and MySQL running in Linux Server.

推荐答案

您应该使用 Cron 做到这一点.在 Wikipedia页面中查看示例.

You should use a Cron job to do it. Check out the examples on the Wikipedia page.

Cron作业应使用运行必要任务的php可执行文件调用脚本.

The Cron Job should call a script using the php executable that runs the necessary task.

这篇关于如何在计划的时间运行PHP脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆