scala - 如何每天晚上 11 点运行任务 [英] scala - How to run a task every day a 11PM
本文介绍了scala - 如何每天晚上 11 点运行任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用 playframework,我尝试运行一个函数来每天晚上 11 点发送邮件,但我不知道该怎么做.我在互联网上找到了很多答案,但我还没有适应 Scala 语言,你有教程的例子吗?
With playframework, I'm trying to run a function to send a mail every day at 11PM but I don't know how to do. I found many answers accros the internet but I haven't managed to adapt with Scala language, do you have a example of tutorial ?
推荐答案
看看 Akka Scheduler 和 玩!预定作业
我个人更喜欢玩!使用 cron 的调度程序.因此,在示例(复制/粘贴)中,您可以创建一个类似于以下内容的 Scala 类:
I'll personally prefer Play! scheduler which uses cron. So in the example (copy/paste), you could create a Scala class similar to this:
import play.jobs.*;
/** Fire at 12pm (noon) every day **/
@On("0 0 12 * * ?")
public class Bootstrap extends Job {
public void doJob() {
Logger.info("Maintenance job ...");
...
}
}
这篇关于scala - 如何每天晚上 11 点运行任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文