Igor Ganapolsky Igor Ganapolsky - 3 months ago 13
Node.js Question

Node.js script not executing from crontab

I have a crontab entry that is supposed to execute a node.js script like this:

*/5 * * * * node /home/campaigns/reporting/UNIT_TESTS/testCron.js > /home/campaigns/reporting/UNIT_TESTS/cron.log


However, it doesn't execute and the log file isn't updated. When I run the script manually, everything works though. Any ideas??

Thank you,
Igor

Answer

Try making a script with the command:

script.sh:

#!/usr/bin/env sh
node /home/campaigns/reporting/UNIT_TESTS/testCron.js > /home/campaigns/reporting/UNIT_TESTS/cron.log

and then adding that to cron:

*/5 * * * * /path/to/script.sh

make sure to make the script executable (chmod +x script.sh)

Comments