简体   繁体   English

多个自动化任务来运行ubuntu 10.04服务器

[英]multiple automated tasks to run ubuntu 10.04 server

I need to run automated tasks every 15. The tasks is for my server (call it server A, Ubuntu 10.04 LAMP) to query for updates to another server (Server B). 我需要每15个运行一次自动化任务。这些任务供我的服务器(称为服务器A,Ubuntu 10.04 LAMP)查询对另一台服务器(服务器B)的更新。

I have multiple users to query for, possibly 14 (or more) users. 我有多个用户要查询,可能有14个(或更多)用户。 As of now, the scripts are written in PHP. 到目前为止,这些脚本都是用PHP编写的。 They do the following: 他们执行以下操作:

  1. request Server B for updates on users 请求服务器B更新用户信息
  2. If Server B says there are updates, then Server A retrieves the updates 如果服务器B说有更新,则服务器A检索更新
  3. In Server A, update DB with the new data for the users in 在服务器A中,使用以下用户的新数据更新数据库
  4. run calculations in server A 在服务器A中运行计算
  5. send prompts to users that I received data updates from. 向我发送数据更新的用户发送提示。

I know cron jobs might be the way to go, but there could be a scenario where I might have a cron job for every user. 我知道可能要进行cron作业 ,但是在某些情况下,我可能为每个用户提供cron作业。 Is that reasonable? 那合理吗? Or should I force it to be one cron job querying data for all my users? 还是应该强迫它成为所有用户查询数据的一项cron作业?

Also, the server I'm querying has a java api that I can use to query it. 另外,我正在查询的服务器具有一个Java API,可以用来查询它。 Which means I could develop a java servlet to do the same. 这意味着我可以开发一个Java servlet来做到这一点。 I've had trouble with this approach but I'm looking for feedback if this is the way to go. 我在使用这种方法时遇到了麻烦,但是如果这样做,我正在寻求反馈。 I'm not familiar with Tomcat and I don't fully understand it yet. 我对Tomcat不熟悉,我还不太了解。

Summary: I need my server to run tasks automatically every 15 mins, the requests data from another server, updates its DB and then send prompts to users. 简介:我需要服务器每15分钟自动运行一次任务,从另一台服务器请求数据,更新其数据库,然后将提示发送给用户。 What's are recommended approaches? 建议的方法是什么?

Thanks for your help! 谢谢你的帮助!

Create a single script, triggered by cron, that loops through each user and takes all three steps for each user: Pseudo code: 创建一个由cron触发的脚本,该脚本循环遍历每个用户并为每个用户执行所有三个步骤:伪代码:

query for list of users from local DB;
foreach(users as user){
   check for updates;
   if(updates){
      update db;
      email user;
   }
}

If you have a lot of users or the API is slow, you'll either want to set a long script timeout (ini_set) or you could add a TIMESTAMP DB column "LastUpdateCheck" and run the cron more often (every 30 seconds?) but limiting the update/API query to one or two users per instance (those with the oldest update times) 如果用户很多或API速度很慢,则可以设置较长的脚本超时时间(ini_set),也可以添加TIMESTAMP DB列“ LastUpdateCheck”并更频繁地运行cron(每30秒?)但将更新/ API查询限制为每个实例一个或两个用户(更新时间最久的用户)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM