3

I want to execute a jake task on crontab for my node js project. I learned to create and run jake in node js. And i also learned to work with crontab. If i add the following to create cronjob, the jake task didn't gave the right result.

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

But if i run in command line manually it running perfectly.

Thanks in advance, can anyone tell me what change to made to make it to run properly.

4

2 回答 2

0

不是 100% 肯定,因为您没有说它以何种方式不起作用,但我会说它很可能不会以您的用户身份运行。确保当你添加 te cronkob 时,它就像你一样,就像这样

crontab -u YOURUSERNAMEHERE -e

如果这很好,您可能需要检查路径变量以查看是否正确包含了 jake。最简单的方法是设置一个玉米作业来运行,它与你的 $PATH 环境变量和他的杰克路径相呼应

$ echo $PATH >> /tmp/foo; which jake >>/tmp/foo
于 2014-02-24T06:50:11.060 回答
0
  1. 确保全局安装了jake
  2. 确保从绝对路径更改目录并使用 “&&”运行下一个命令

检查下面的 cron 示例

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

于 2015-09-02T12:24:44.470 回答