服务器可以运行脚本
所以我意识到这个问题很广泛,因为我正在寻找一个起点。
例如,是否有可能拥有一台每天或每 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
可能有某种方法可以在服务器端运行 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 googlecrontab
. You need (root) access to the server though.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
是的,这是完全可能的。在 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).