1

I want my node.js program to automatically execute at midnight or some particular time, every day.

I have some idea about cron, but can anyone specify me how to do this?

sachsure
  • 828
  • 1
  • 17
  • 30
  • 1
    http://stackoverflow.com/questions/3984134/cron-that-will-run-a-ruby-script-every-day-at-midnight – F.bernal Apr 29 '16 at 15:19
  • This is very basic crontab usage. `man 1 crontab` will tell you how to use the `crontab` command, and `man 5 crontab` will explain the syntax and semantics of a crontab. – Keith Thompson Apr 29 '16 at 15:50

2 Answers2

1

On Linux, you can simply run crontab -ewhich will open a cron file in your default editor.

Then to have your node program running every day at midnight you'd have to enter :

00 00 * * * node /path/yournodeapp.js

And save it.

I suggest you read a bit about cron jobs, they are quite powerful but very easy to use.

This is my usual cheatsheet.

zoubida13
  • 1,738
  • 12
  • 20
0

Look into the cron module on NPM. It allows you to execute arbitrary node.js code at predefined intervals or times of day.

hownowbrowncow
  • 465
  • 1
  • 5
  • 18