简体   繁体   English

Ruby on Rails-用户计划任务

[英]Ruby on Rails - Users Scheduling Tasks

I am working on an application which people can sign up to and schedule tasks to be done. 我正在开发一个人们可以注册并计划要完成的任务的应用程序。

When the user schedules a task they enter a date and time. 用户安排任务时,他们输入日期和时间。 I want the application to wake up and send an email to the user at the date and time they have entered. 我希望应用程序唤醒并在用户输入的日期和时间向用户发送电子邮件。

I am unsure what gems/plugins to use in rails to achieve this, anyone have a suggestion? 我不确定要在导轨中使用哪些gem / plugins来实现这一目标,有人建议吗?

Cheers 干杯

Eef EEF

delayed_job should do the trick. delay_job应该可以解决问题。 It allows you to schedule tasks to run at a particular time. 它允许您安排任务在特定时间运行。 All you need to do is schedule a function that sends an email. 您所需要做的就是安排发送电子邮件的功能。

Run a cron job every minute that runs a rake task that checks the database for any un-run tasks in the past. 每分钟运行一次cron作业,该作业运行一个rake任务,该任务检查数据库中过去是否存在任何未运行的任务。

This way if your system goes down (hint: it will) when you bring it back up the cronjob will pick up the slack left behind. 这样,如果将系统重新启动后系统崩溃(提示:它将),则cronjob将弥补遗留的松弛。

There's also a backgroundrb . 还有一个backgroundrb Also check this thread . 同时检查此线程

The Unix 'at' command is also useful. Unix的“ at”命令也很有用。 Just execute a shell that calls 'at'. 只需执行一个调用“ at”的shell。

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

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