我已经尝试了很多东西,但 cron 只是不会重新启动 pm2。我设置了crontab -e
:
SHELL=/bin/sh PATH=/bin:/sbin:/usr/bin:/usr/sbin
*/10 * * * * /usr/bin/node /usr/bin/pm2 restart all
我输入:
cat /var/log/cron.log
它说:
Apr 2 01:00:01 fatsecret CRON[8202]: (peteblank) CMD (/usr/bin/node /usr/bin/pm2 restart all)
Apr 2 01:00:01 fatsecret CRON[8201]: (peteblank) MAIL (mailed 78 bytes of output but got status 0x004b from MTA#012)
Apr 2 01:10:01 fatsecret CRON[8454]: (peteblank) CMD (/usr/bin/node /usr/bin/pm2 restart all)
Apr 2 01:10:01 fatsecret CRON[8453]: (peteblank) MAIL (mailed 78 bytes of output but got status 0x004b from MTA#012)
所以看起来它每 10 分钟重新启动一次,但事实并非如此。