user240993
user240993

Reputation:

Nodejs for cron jobs

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.

Upvotes: 1

Views: 1778

Answers (1)

Iesus Sonesson
Iesus Sonesson

Reputation: 854

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

Upvotes: 5

Related Questions