【发布时间】:2019-09-19 01:21:42
【问题描述】:
我有一个每分钟运行一个 shell 脚本的 cron 作业。但是我不断得到
/usr/bin/env: node: No such file or directory
restarting
nohup: failed to run command ‘npm’: No such file or directory
作为输出。
我已尝试全局安装 pm2,但这不起作用。
这是我的 Shell 文件:
#!/bin/bash
PATH=$PATH: /home/dev/bin/npm
pID=$(pgrep -x "PM2")
if [ -n "${pID}" ];
then
#do nothing
echo $pID "already running. not restarting."
else
# start it
echo "restarting"
nohup npm ./home/dev/public_node/server.js --production &
fi
应该通过pm2启动server.js文件?
【问题讨论】:
-
添加
PATH=$PATH:<pathToDirContainingPm2>作为第二行。通过在终端中运行type pm2找到该目录。 -
通常在哪里? @MarkSetchell
-
启动终端并运行
type pm2,它会告诉你路径。 -
我更新了我的文件,现在我得到了一个不同的错误