Read the statement by Michael Teeuw here.
Crontab to Restart Magic Mirror does not work
-
@desert-rat what is in the pm2 log??
pm2 logs --lines=50
what user is the cron entry running as?
typically root…but the pm2 entry is setup for pi probably
-
I would try pm2 iso PM2.
And even would advise to use the full path, that can be determined using:
which pm2With Debian it would be /usr/local/bin/pm2
And you can check this log if cron did anything at all:
/var/log/syslogOr edit /etc/rsyslog.conf and remove comment on the line with cron (around line 63)
Then the dedicated cron log will be in /var/log/cron.log.
After editing, restart with „sudo systemctl restart rsyslog“.Good luck,
E.J.
-
@evroom good catch on the uppercase pm2…
@Desert-Rat
everything in Linux is case sensitive -
@sdetweil
Thanks for the quick reply. I changed the crontab. I actually changed it to PM2 START MagicMirror.The process I used was to , via the terminal, pm2 stop MagicMirror. This worked and MagicMirror was stopped sucessfully.
Crontab was updated as above PM2 START MagicMirror.
It did not start.Here are the entries from the log file
Nov 27 13:44:01 raspberrypi CRON[3620]: (pi) CMD (SUDO PM2 START MagicMirror)
Nov 27 13:44:01 raspberrypi CRON[3618]: (CRON) info (No MTA installed, discarding output)
Nov 27 13:55:01 raspberrypi CRON[3661]: (root) CMD (sudo pm2 restart MagicMirror)
Nov 27 13:55:04 raspberrypi CRON[3659]: (CRON) info (No MTA installed, discarding output)
Nov 27 14:17:01 raspberrypi CRON[3772]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly) -
-
Could you please show the crontab ?
$ crontab -l
To get rid of this:
(CRON) info (No MTA installed, discarding output)
you have to add
>/dev/null 2>&1
Try:
44 * * * * /usr/local/bin/pm2 start MagicMirror >/dev/null 2>&1
-
Problem resolved! Outstanding.
My thanks to all who responded.
My mission now is to research the provided solution and try to understand why it worked. Clearly the devil is in the details.
Thanks again to all of you
-
@desert-rat said in Crontab to Restart Magic Mirror does not work:
to understand why it worked.
your crontab entry
44 * * * * PM2 restart MagicMirror
the working crontab entry
44 * * * * /usr/local/bin/pm2 start MagicMirror >/dev/null 2>&1
could be restart as well…
simple, two things
cron runs as root, BUT certain folders are not in the path
so you need to specify the path to the command/usr/local/bin/
second the command is pm2, you tried PM2
in linux EVERYTHING is case sensitiveso yours is command not found, cause there is no command named PM2
-
@sdetweil Thanks Sam! I clearly need some education. Do you have a favorite set of training documentation for newbies
Desert Rat
-
@desert-rat sorry. no idea. my info is gathered over 20+ years
there are online linux courses, but I don’t know where they start, or how deep they go, how fast.
I have a near photographic memory which is a blessing and a curse…