Reputation: 65
I am trying to run a Cronjob in AWS (EC2). My crontab file looks like this 1 * * * * node /var/apps/project-name/file.js
This is supposed to trigger my file.js every 1 minute but it is not happening. Can someone help me where I am wrong?
Pls Comment if more details are needed
Upvotes: 1
Views: 2743
Reputation: 2525
There is few options:
1. Your cron user (who executes cron) have no permissions on file
To fix this, you can add permissions to execute with this command sudo chmod 755 /var/apps/project-name/file.js
2. Cron user can't find node
, so you need to specify full path.
To find your node.js on server, run which node
and than add it to cron file
Like this:
0 * * * * /usr/bin/node /var/apps/project-name/file.js
Upvotes: 2