npm 的环境变量是配置了的, 直接运行 sh start.sh 都是可以运行。 但用定时任务来执行就找不到 npm 命令了。
这是报错
begin...
end
----------------------------------------------------------------------------
nohup: failed to run command ‘npm’: No such file or directory
★[2021-12-30 10:57:01] Successful
----------------------------------------------------------------------------
这是脚本 start.sh 的内容
echo "begin..."
cd /root/admin
nohup npm start &
echo "end"