Nodejs for cron jobs

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-14 03:35:08

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/14916507/nodejs-for-cron-jobs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!