有一个脚本可以在后端连续执行某些操作,而无需浏览器

发布于 2024-11-27 18:52:11 字数 402 浏览 0 评论 0原文

我有点困惑。所以请对我宽容一些。采用任何使用 MVC 实现的标准 Web 应用程序,例如 codeigniter 或 Rails。仅当浏览器正确发送请求时,脚本才会执行。因此,当用户登录并发送请求时,服务器会收到请求并向他发送响应。

现在考虑这样的场景:除了常规应用程序之外,我还需要后端进程之类的东西。例如,检查投标时间是否结束并向投标人发送投标结束邮件并选择中标者的脚本。现在,所有这些操作都必须在投标时间结束后自动完成。

现在,如果此脚本是常规应用程序的一部分,那么它应该由客户端(浏览器)触发,但我不希望发生这种情况。这应该像一个机器人脚本,必须在服务器上运行,检查数据库中是否有这样的事件和模式。

我该如何去做这样的事情。也可以在常规共享或专用主机上实现此功能,在这些主机上我们没有 shell 访问权限,但只有 ftp 访问权限。

I am kind of confused. So pls go easy on me. Take any standard web application implemented with mvc, like codeigniter or rails. The scripts gets executed only when a browser sends request right. So when a user logs in and sends request the server recieves it and sends him response.

Now consider the scenario where apart from the regular application i also need something like a backend process. For example a script which checks whether a bidding time is closed and sends the mail to the bidder that the bidding is closed and chooses the bid winner. Now all these actions has to be done automatically as soon as the bidding time ends.

Now if this script is part of a regular app then it should be triggered by the client(browser) but i dont want that to happen. This should be like a bot script which must run on the server checking the DB for events and patterns like this.

How do i go about doing something like this. Also is this possible to have this implemented on a regular shared or dedicated hosting where we dont have shell access but only ftp access.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

栖迟 2024-12-04 18:52:11

您必须将脚本编写为独立程序,然后让它在后台连续运行,或者让 cron (或其他一些调度服务;也仅在您只对基于时间的事件感兴趣时才有效)为您执行它。

可能有一些主机采用无 shell 方式来执行此操作(用于管理后台进程或其他内容的精美 GUI 界面),但仅具有 FTP 访问权限的普通 Web 主机肯定不会这样做。

You'd have to write your script as a standalone program and either have it run continuously in the background or have cron (or some other scheduling service; also only works if you're only interested in time-based events) execute it for you.

There are probably hosts that have shell-less ways to do this (fancy GUI interfaces for managing background processes or something,) but your run of the mill web host with only FTP access definitely doesn't.

半边脸i 2024-12-04 18:52:11

您需要一个cron 作业,它在Linux 上很容易设置。该 cron 作业将使用您的脚本调用 PHP 的命令行版本,或者使用 curlwget 创建本地 HTTP 请求。

如果您无权访问,那么您需要一个自动生成定期 HTTP 请求的外部站点。一种便宜的方法是 setcronjob

You need a cron job, it's easy to set up on linux. That cron job will either call the command line version of PHP with your script or create a local HTTP request with curl or wget.

If you don't have access then you need an external site that automatically generates periodic HTTP requests. A cheap one is setcronjob.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文