Ich habe Probleme mit meinem Beispiel mit einem cron Tab Neustartcron erstellen PM2 Instanz neu zu starten, schlägt fehl
#!/usr/bin/node
*15 * * * * /usr/bin/node /usr/bin/pm2 restart 4
Aber mein Problem ist dabei, dass ich zwei PM2 Dämonen haben. Und die, die ich so in /opt.pm2 wollen, dass jedes Mal, wenn ich will PM2 verwenden Ich brauche diesen Befehl verwenden
export PM2_HOME="/opt/.pm2"
und ich muss wissen, wie diese env Variable in meinem crontab passieren Instanz neu zu starten 4 cause in/usr/bin/pm2 Habe ich meine App nicht laufen verstehen?
aber ich habe den Fehler
From [email protected] Sun Nov 12 11:23:01 2017
Return-Path: <[email protected]>
X-Original-To: root
Delivered-To: [email protected]
Received: by ip120.ip-46-105-248.eu (Postfix, from userid 0)
id E84CA100921; Sun, 12 Nov 2017 11:23:01 +0000 (WET)
From: "(Cron Daemon)" <[email protected]>
To: [email protected]
Subject: Cron <[email protected]> /usr/bin/node /usr/bin/pm2 restart 4
Content-Type: text/plain; charset=UTF-8
Auto-Submitted: auto-generated
Precedence: bulk
X-Cron-Env: <XDG_SESSION_ID=4300>
X-Cron-Env: <XDG_RUNTIME_DIR=/run/user/0>
X-Cron-Env: <LANG=en_US.UTF-8>
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/root>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=root>
X-Cron-Env: <USER=root>
Message-Id: <[email protected]>
Date: Sun, 12 Nov 2017 11:23:01 +0000 (WET)
Use --update-env to update environment variables
[PM2] Applying action restartProcessId on app [4](ids: 4)
[PM2][ERROR] Process 4 not found
┌──────────┬────┬──────┬─────┬────────┬─────────┬────────┬─────┬─────┬──────────┐
│ App name │ id │ mode │ pid │ status │ restart │ uptime │ cpu │ mem │ watching │
└──────────┴────┴──────┴─────┴────────┴─────────┴────────┴─────┴─────┴──────────┘
Module activated
┌───────────────┬─────────┬────────────┬────────┬─────────┬─────┬─────────────┐
│ Module │ version │ target PID │ status │ restart │ cpu │ memory │
├───────────────┼─────────┼────────────┼────────┼─────────┼─────┼─────────────┤
│ pm2-logrotate │ 2.2.0 │ N/A │ online │ 0 │ 0% │ 91.223 MB │
└───────────────┴─────────┴────────────┴────────┴─────────┴─────┴─────────────┘
Use `pm2 show <id|name>` to get more details about an app
So sagen Sie zu tun "*/15 * * * * env PM2_HOME ="/opt/.pm2 "/ usr/bin/node/usr/bin/pm2 Neustart 4"? –
@ AndréBastos Ja, das sollte funktionieren. Aber probiere es in deiner Shell aus, bevor du es in crontab bringst. – sapht
Siehe meine aktualisierte Antwort bitte @ sapht1 –