使用 cron 每 12 小时重新启动 pm2 应用程序 [英] Restart pm2 app every 12h with cron

查看:45
本文介绍了使用 cron 每 12 小时重新启动 pm2 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试过了,但没有用:

SHELL=/bin/bash
PATH=/usr/lib/node_modules/pm2/bin
* 0,12 * * * pm2 restart all

我做错了什么?

推荐答案

使用 crontab -e 编辑 cron 并添加以下内容:

Edit cron with crontab -e and add the following:

0 */12 * * */usr/bin/node/usr/bin/pm2 restart all

对于时间表,每 12 小时使用 0 */12 * * *,或 0 0,12 * * * 用于 0:00 和 12:00具体来说.(您的计划,* 0,12 * * *,将在 0 小时和 12 小时、0:00、0:01、0:02...的每一分钟触发一次)

For the schedule, use 0 */12 * * * for every 12 hours, or 0 0,12 * * * for 0:00 and 12:00 specifically. (Your schedule, * 0,12 * * *, would trigger every minute of hour 0 and hour 12, 0:00, 0:01, 0:02...)

对于命令,正如 fedorqui 提到的,使用节点路径,然后是 pm2 路径和 pm2 选项.使用 which nodewhich pm2 来获取节点和 pm2 的路径.

For the command, as fedorqui mentioned, use the path to node followed by the path to pm2 and the pm2 options. Use which node and which pm2 to get the path to node and pm2.

这篇关于使用 cron 每 12 小时重新启动 pm2 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆