开发者

How to run a Cron job for Node.js

开发者 https://www.devze.com 2023-02-09 00:24 出处:网络
I have a cron job that call a shell script. */2 * * * * sh cron_test.sh >> output.log In side the shell script, I run some command lines like:

I have a cron job that call a shell script.

*/2 * * * * sh cron_test.sh >> output.log

In side the shell script, I run some command lines like:

#!/usr/bin

./mongo/bin/mongodump .....

FILE_NAME='abc'

node mynode.js $FILENAME

It runs if I just call cron_test.sh in command prompt. However, it doesn't run node if it is run by cronjob. It does run the mongodump command. So, what's wrong? is there anything I have to set for开发者_如何学C permission, etc?


thanks.. I find it out..

either I need to specify the node path or do that in the sh script:

nodejs/node myscript.js

where nodejs/node is where the node installed.

0

精彩评论

暂无评论...
验证码 换一张
取 消