Answer the question
In order to leave comments, you need to log in
How to execute nodejs scripts in crontab?
I tried to force the script to be executed on node with a certain periodicity, but there were problems.
The script should write to the logs. Logs are empty. As a result, I created a test script that looks like this:
The task is written in crontab like thisconsole.log(Number(new Date()));
* * * * * /usr/bin/node /path/to/script/test.js >> /path/to/script/test.log
Answer the question
In order to leave comments, you need to log in
In general, I did not immediately think of logging stderr, but there
And the nature of this error is not very clear to me, I kind of directly indicate the path to the node.
In general, the solution is a crutch, I found it here : create a file execute.sh. Use env in it:
#!/usr/bin/env sh
node /path/to/file/test.js >> /path/to/file/test.log
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question