How to run jake on crontab for a node js project?

I want to execute a jake task on crontab for my node js project. I learned how to create and run jake in node js. And I also learned to work with crontab. If I add the following to create a cronjob, the jake task did not give the correct result.

* * * * * jake -f ~/Documents/Dev/MyProject-Workplace/web-njs/jake/import/my_jake_file jake_state:add_states >> ~/states.txt

But if I run on the command line manually, it works fine.

Thanks in advance if anyone can tell me what changes have been made to make it work properly.

+3
source share
2 answers

Not 100% sure, since you are not saying how this does not work, but I would say that it is most likely not launched as your user. Make sure that when you add te cronkob, it is the way you are, so

crontab -u YOURUSERNAMEHERE -e

, , , jake. , $PATH env var jake

$ echo $PATH >> /tmp/foo; which jake >>/tmp/foo
0
  • , jake .
  • "&"

cron

0 2 * * * cd/home/user/work/lib/& && & && jake foo: bar -f example.js

0

All Articles