服务器可以运行脚本

发布于 2024-12-07 14:02:39 字数 230 浏览 5 评论 0原文

所以我意识到这个问题很广泛,因为我正在寻找一个起点。

例如,是否有可能拥有一台每天或每 2 分钟运行一次 PHP 脚本的服务器?

基本上,我不想将这些任务放在用户脚本中,因为我担心它们会运行超出必要的次数,而且我宁愿将其分开。

我希望保留 javascript、PHP 或 SQL,因为我没有时间学习一门新的语言 atm,所以如果你们中有任何人有任何好的地方可以让我阅读这方面的内容,我将非常感激。

So I realize this question is broad, as I'm looking for a place to start.

Is it possible to have a server that for example runs PHP scripts every day, or every 2 minutes?

Pretty much, I don't want to put these tasks in the users script, because I'm scared they would get run a lot more than is necessary, and I'd prefer to keep it separate.

I'm looking to keep it javascript, PHP or SQL as I don't have the time to learn a new language atm, so if any of you have any good places for me to read up on this, I would greatly appreciate it.

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

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

发布评论

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

评论(3

一身软味 2024-12-14 14:02:39

可能某种方法可以在服务器端运行 javascript,但我肯定会坚持使用 PHP。顺便说一句,SQL 不是脚本...

您可以使用 cronjobs 每 x 分钟/小时/天执行 PHP 脚本。只需谷歌crontab即可。不过,您需要(root)访问服务器。

There might be some way to run javascript on the server side, but I'd certainly stick to PHP. SQL is not a script, by the way...

You can execute your PHP scripts every x minutes / hours / days using cronjobs. Just google crontab. You need (root) access to the server though.

无人接听 2024-12-14 14:02:39

JavaScript 不会像你期望的那样在服务器端运行。我建议你考虑编写一个 cron 作业来运行 bash 文件。只需最少的研究即可完成。

Cron 简介

Bash 介绍

Javascript will not run server side as you are expecting. what I would suggest is you look into writing a cron job to run a bash file. It would take minimal research to complete.

Cron Intro

Bash Intro

木緿 2024-12-14 14:02:39

是的,这是完全可能的。在 Linux 上(Mac 也是如此?),您使用 cron 作业调度程序运行您的脚本。

对于 Windows,您可以尝试Windows 任务计划程序。它提供了类似的功能。

您可以使用 cron 运行几乎任何脚本,但不能运行 JavaScript(除非您将其用于服务器端)。

Yes, it's completely possible. On Linux (Mac too?), you use the cron job scheduler to run your scripts.

For Windows, you can try the Windows Task Scheduler. It provides similar functionality.

You can run just about any script with cron, but not JavaScript (unless you use it for serverside stuff).

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