简体   繁体   English

如何在服务器上连续执行程序? 以及使用哪种语言?

[英]How to execute a program continuously on a server? And which language to use?

Okay this is my first post here so please forgive me if i mess something up. 好的,这是我在这里的第一篇文章,所以如果我搞砸了,请原谅我。

I am trying to build a web program that will send email with content drawn from a db at a time specified in the db to a email address specified in the db. 我正在尝试构建一个Web程序,该程序将在db中指定的时间将包含从db中提取的内容的电子邮件发送到db中指定的电子邮件地址。 I am fluent in php & mysql and initially assumed i would base this program on those languages but i cant figure out how to use php to achieve my purpose. 我精通php&mysql,起初以为我会以这些语言为基础编写该程序,但我无法弄清楚如何使用php达到我的目的。 So i assume i will have to turn to another language, but i haven't the vaguest idea of which to turn to. 因此,我认为我将不得不求助于另一种语言,但是我没有最模糊的想法。

My other problem is that i don't know how to setup whatever script i end up making to run continuously. 我的另一个问题是我不知道如何设置最终使脚本连续运行的脚本。

Thanks for the suggestion Russ, to begin with it will be hosted locally either on my centos box or my xampp server, probably the later until it is working properly and i don't know about the future as it is just an idea right now. 感谢您的建议,Russ首先将在本地托管在我的centos盒或xampp服务器上,可能稍后再托管,直到它正常工作为止,我不知道将来,因为它只是一个想法。

EDIT: I actually did this in perl, it did end up a little different than originally planned but it worked so im happy. 编辑:我实际上是在perl中完成此操作的,它的最终结果与最初计划的有所不同,但是我非常高兴。

Thanks to all who answered. 感谢所有回答。

If you are concerning only on how to schedule the send email function, you can try some open source scheduler like 如果只考虑如何安排发送电子邮件功能,则可以尝试使用一些开源的调度程序,例如

http://www.phpjobscheduler.co.uk/ http://www.phpjobscheduler.co.uk/

Crontab with PHP can do what you want. 使用PHP的Crontab可以满足您的需求。 See: Newbie: Intro to cron 请参阅: 新手:cron简介

You can also write a PHP daemon to do the job. 您也可以编写一个PHP守护程序来完成这项工作。

MySQL has events that can run every day/hour/minute. MySQL具有可以每天/每小时/分钟运行的事件。

See: http://dev.mysql.com/doc/refman/5.1/en/events.html 参见: http : //dev.mysql.com/doc/refman/5.1/en/events.html

It's generally a bad idea to let the DB-server (MySQL) run external program though because that's a security risk. 让DB服务器(MySQL)运行外部程序通常是一个坏主意,尽管这样做存在安全隐患。
So let the DB handle DB events and let crontab handle unix events. 因此,让数据库处理数据库事件,让crontab处理Unix事件。
Windows has the at command. Windows具有at命令。

You need to use Cronjobs to achieve your goal. 您需要使用Cronjobs才能实现目标。

You can find more info about how to use here . 您可以在此处找到有关如何使用的更多信息。

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

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