crontab -e 定时任务 运行命令无效后处理(已解决)

这里以node 命令为例子. 

在 crontab -e 中写好0 0 * * * pm2 restart 1  之后报错

主要的报错是

sudo: pm2: command not found
sudo: pm2: command not found
sudo: pm2: command not found
sudo: pm2: command not found
sudo: pm2: command not found
sudo: pm2: command not found
sudo: pm2: command not found
sudo: pm2: command not found
sudo: pm2: command not found
/usr/bin/env: node: No such file or directory
/usr/bin/env: node: No such file or directory
/usr/bin/env: node: No such file or directory
/usr/bin/env: node: No such file or directory
/usr/bin/env: node: No such file or directory

这都是找不到,跟 直接在命令行自己输入不一样. 每个命令都要指定来源  比如这样

*/1 * * * * /usr/local/bin/node /usr/local/bin/pm2 stop 1 >> /srv/jekod/zeus/cron.log 2>&1

并且打印出 日志看下结果

你可能感兴趣的:(我的碎屑世界,linux,服务器,ubuntu)