Read the statement by Michael Teeuw here.
pm2 doesnt work with crontab
-
Hi,
try this:
crontab -e
with connected user:05 20 * * * /usr/bin/pm2 start mm 15 07 * * * /usr/bin/pm2 start mm 30 21 * * * /usr/bin/pm2 stop mm
- sudo crontab -e is not necessary.
- I do not understand the start at 20:05 (first line)
- my pm2 is in /usr/bin
- always use full path in crontab
If you’re not sure where PM2 is you can use
find / -iname pm2
in the console. Important is the full path in crontab.
/home/chris/.nvm/versions/node/v22.9.0/lib/node_modules/pm2/pm2
would be an alternative for me. -
@chrisfr1976 said in pm2 doesnt work with crontab:
find / -iname pm2
/usr/local/bin/pm2 /usr/local/lib/node_modules/pm2 /usr/local/lib/node_modules/pm2/bin/pm2 /usr/local/lib/node_modules/pm2/lib/templates/logrotate.d/pm2 /usr/local/lib/node_modules/pm2/pm2 /home/pi/MagicMirror/node_modules/.bin/pm2 /home/pi/MagicMirror/node_modules/pm2 /home/pi/MagicMirror/node_modules/pm2/bin/pm2 /home/pi/MagicMirror/node_modules/pm2/lib/templates/logrotate.d/pm2 /home/pi/MagicMirror/node_modules/pm2/pm2
Which is the true one and one to use?
-
@plainbroke
Then use this:
/usr/local/bin/pm2 -
@chrisfr1976
@sdetweil
Thank you both for the help.
/usr/local/bin/pm2 restart mm
worked so I set it up to stop now and if (fingers crossed) works.
I am golden.
Wonder why I never had to use the full path before?
Maybe my pm2 path was /home/pi/pm2 before.
Doesn’t really matter as long as it works, I am a happy camper.
It works.
Thank you so much… I will mark this solved.
Well I would if I could… strange.By the way " which pm2 " shows the path that I needed to use in crontab -e
-
@plainbroke awesome
i should have remembered the path problem