Stefanos Chrs
Stefanos Chrs

Reputation: 2528

nodejs script not running in crontjob

Hello I would like to add a nodejs script to cronjob and I can't seem to get it working.. I am using shell to call the node script. I have tried making another nodejs script to test if its working, I mean if I had the paths wrong but that one is working.

runScript

#!/bin/sh
echo `date +%s` >> /path/cron.log
/usr/bin/node /path/main.js >> /path/cron.log

runScript1

#!/bin/sh
echo `date +%s` >> /path/cron.log
/usr/bin/node /path/test.js >> /path/cron.log

and in cron:

0       *       *       *       *       /path/runScript
0       *       *       *       *       /path/runScript1

So to recap I get both dates printed in the cron.log but only the test.js file runs after, the main.js is not running. When I tried to run manually like this ./runScript it worked.

Upvotes: 0

Views: 991

Answers (1)

Stefanos Chrs
Stefanos Chrs

Reputation: 2528

After all the problem was the NodeJS Modules path inside the script, so the Bash and Cron were ok!

Upvotes: 0

Related Questions