Quite simply, I have node script that I want to execute once a month.
30 6 1 * * node /home/steve/example/script.js
But this doesn't work, presumably because of path or the shell the command is being ran under. I've tried the following means of executing node via cron (tested with -v):
steve@atom:~$ node -v v0.4.2 steve@atom:~$ sh node -v sh: Can't open node steve@atom:~$ bash node -v /usr/local/bin/node: /usr/local/bin/node: cannot execute binary file steve@atom:~$ /usr/local/bin/node -v v0.4.2 steve@atom:~$ sh /usr/local/bin/node -v /usr/local/bin/node: 1: Syntax error: "(" unexpected steve@atom:~$ bash /usr/local/bin/node -v /usr/local/bin/node: /usr/local/bin/node: cannot execute binary file
I've ran out of ideas to try, any advice?
Entry to Run Our Node File Show activity on this post. Now, if you change the node version in your project and update your . nvmrc with the proper version number and pull the new code onto the server, the next time the cron job runs it will run with version of node specified.
It is a wildcard for every part of the cron schedule expression. So * * * * * means every minute of every hour of every day of every month and every day of the week .
To use current data in the future you can use binding: const schedule = require('node-schedule'); const date = new Date(2012, 11, 21, 5, 30, 0); const x = 'Tada!' ; const job = schedule. scheduleJob(date, function(y){ console.
just provide the full path to node /usr/local/bin/node
in your cron job like:
30 6 1 * * /usr/local/bin/node /home/steve/example/script.js
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With