Linux:我应该使用什么来运行基于日历系统的终端程序?

发布于 2024-12-09 19:01:34 字数 557 浏览 0 评论 0原文

抱歉,这个问题非常模棱两可,我真的不知道如何表达,但希望我可以在这里为您提供更多细节。

我正在开发一个项目,用户可以登录网站并预订服务器来运行游戏特定的时间。当时间到时,服务器停止运行,服务器上的玩家被踢出。网站部分不是问题,我正在 PHP 中执行此操作,一切正常。它有一个日历系统来预订服务器,并可以根据用户的需求生成配置文件。

我的问题是我应该使用什么来在正确的时间使用这些配置文件在 Linux 机器上运行特定的游戏服务器?我已经使用 bash 脚本和 cron 来完成这个工作,但它看起来很不优雅。它实际上使用 FTP 连接到网站,以便下载所有必要的配置文件并将它们放入该游戏和时间的文件夹中。我想知道是否有更好的方法来做到这一点。也许用 C 语言编写一个程序,但我不知道如何去做。

(我并不是要求有人握住我的手并告诉我“在这里编写这段代码”,只是一些解决这个问题的更好方法的想法)

非常感谢大家!

编辑:网络服务器是一台完全不同的机器。理论上,我希望拥有多个游戏服务器,其中每个服务器都“连接”(目前是 FTP)到网络服务器,获取一个文件,说明它在特定时间必须执行的操作,并下载任何关联的文件,然后断开连接。

Sorry about the really ambiguous question, I really have no idea how to word it though hopefully I can give you more detail here.

I am developing a project where a user can log into a website and book a server to run a game for a specific amount of time. When the time is up the server stops running and the players on the server are kicked off. The website part is not a problem, I am doing this in PHP and everything works. It has a calendar system to book a server and can generate config files based on what the user wants.

My question is what should I use to run the specific game server on the linux box with those config files at the correct time? I have got this working with bash scripts and cron, but it seems very un-elegant. It literally uses FTP to connect to the website so it can download all the necessary config files and put them in a folder for that game and time. I was wondering if there was a better way of doing this. Perhaps writing a program in C, but I am not sure how to go about doing this.

(I am not asking for someone to hold my hand and tell me "write this code here", just some ideas of a better way of approaching this problem)

Thanks so much guys!

Edit: The webserver is a totaly different machine. I would theoreticaly like to have more than one game server where each of them "connects" (at the moment FTP) to the webserver, gets a file saying what it has to do at a specific time and downloads any associated files then disconnects.

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

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

发布评论

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

评论(2

慕烟庭风 2024-12-16 19:01:34

我认为 at 比 cron 更适合运行一次性作业。

为了更好地下载文件等,您应该提供有关您的设置的更多详细信息(例如,网站和游戏服务器,它们是否在同一台机器上?或同一网络?等等)。

I think at is better suited for running one time jobs than cron.

For a better approach for the downloading files etc, you should give more details on your setup (like, the website and the game server, are they on the same machine? Or the same network? etc etc.

蓝天白云 2024-12-16 19:01:34

您需要一个分布式任务调度程序。这样,您可以:

  1. 安排命令“X”在特定时间运行。
  2. 指定机器(或要求它从可用机器池中选择一台机器)

,当用户选择游戏服务器和时间时,Web 服务器将通过命令行或 Web 服务向此调度程序发送请求。

您可以查看:http://www.acelet.com/super/SuperWatchdog/ index.html

编辑:

还有一个选项:http://jobscheduler.sourceforge.net/

You need a distributed task scheduler. With that, you can:

  1. Schedule command "X" to be run at a certain time.
  2. Specify the machine (or ask it to pick a machine from a pool of available machines)

Webserver would send request to this scheduler via command line or via web service when user selects a game server and a time.

You can have a look at : http://www.acelet.com/super/SuperWatchdog/index.html

EDIT :

One more option :http://jobscheduler.sourceforge.net/

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