Nodejs用于cron作业 [英] Nodejs for cron jobs

查看:169
本文介绍了Nodejs用于cron作业的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个主干应用程序,用户可以进行预定的事件。对于这些事件,我假设我需要使用一些类型cron调度。这将是每天约100个工作运行。



从我的理解cpanel使用php crob工作(或者吗?)任何一种方式我不想使用php。



有可能让nodejs做某种类型的调度,它会在预定的时间运行一个特定的事件(在这种情况下是ajax的帖子)未来?



也不要与计时器混淆,从现在开始,在特定时间内执行某种方法。一个更好的例子你会做xyz下午4点星期一2012年2月25日



我也想知道如果服务器重新启动,一切都会重置。

$ b $

Cron可以运行服务器/计算机上的任何脚本或程序理解



在这种情况下(如果我正确地知道node.js),你可以在dev / null中执行一个wget来在node.js服务器上运行应用程序



Cron的工作原理如下:

 #* * * * *已执行
# - - - - -
#| | | | |
#| | | | + -----星期几(0-6)(星期日= 0)
#| | | + -------月(1 - 12)
#| | + ---------月份(1 - 31)
#| + -----------小时(0 - 23)
#+ ------------- min(0 - 59)

示例web脚本运行:
* / 15 * * * * wget http://example.com/example.js -qO / dev / null



这意味着每十五分钟类似这样常常无处不在^^)
15 * * * *每小时通过15分钟


I have a backbone application where users can make scheduled events. For these events I assume I will need use some type cron scheduling. It would be around 100 jobs ran a day.

From my understanding cpanel use php for crob jobs (or does it?) either way I don't want to use php.

Is it possible to have nodejs do some type of scheduling where it will run a particular event (in this case a ajax posts) at scheduled times through out the day for a considerable amount of days in the future?

Also not to be confused with timers where you do some method in a particular amount of hours from now. A better example you be do "xyz" 4pm Monday 2/25/2012

I also wondering would everything reset if the server is restarted.

Any help is appreciated.

解决方案

Cron can run any script or program that the server/computer understands

In this case (if i know node.js correctly) you could do a wget into dev/null to run the application on your node.js server

Cron works like this:

#*     *     *   *    *        command to be executed
#-     -     -   -    -
#|     |     |   |    |
#|     |     |   |    +----- day of week (0 - 6) (Sunday=0)
#|     |     |   +------- month (1 - 12)
#|     |     +--------- day of        month (1 - 31)
#|     +----------- hour (0 - 23)
#+------------- min (0 - 59)

Example web script run: */15 * * * * wget http://example.com/example.js -qO /dev/null

This means every fifteenth minute (or something like that often everyhow ^^) 15 * * * * Means 15 minutes passed every hour

这篇关于Nodejs用于cron作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆