Read the statement by Michael Teeuw here.
Stop and Start MM on a schedule
-
@plainbroke cron typically runs as root, but the pm2 info was saved under some user
you can specify the username in crontab somehow
-
-
@plainbroke does pm2 launch from cron?
-
@plainbroke Are you running from a Pi?
I used to have scheduled on/off times like this and I used to turn on/off the HDMI port of the Pi at the specified times.
As the screen I had it attached to no longer detected an output source, it would then go into sleep mode until the assigned time the script enabled the HDMI interface again.I don’t recall the actual command/settings I used to do it, but it was similar to :
// To turn off
xrandr --output HDMI-1 --off
//to turn on.
xrandr --output HDMI-1 --auto -
@DarrenO-0 I would suggest having a look at the following post I created. I use it to turn my monitor on and off at scheduled times. Not restarting the Pi though.
-
@mumblebaj
Not wanting to turn off the screen, simply because it is a pain to reach the power button to turn it back on, and no remote to get into setup of the TV it was a $40 used tv I bought. it works but I just leave it on and stop MM with a black screen and and the bar in black with bright green letters. It is very very dim. I am going to add the
user pi and the path home/pi to the cron job and see what happens.Thanks for the links
All of you.@sdetweil
not sure yet if pm2 is working in cron?
hoping the change will work. -
@DarrenO-0
@mumblebaj
@sdetweil
Is there a way to run a cron job?
I have done a few google searches with no results that worked. -
@plainbroke said in Stop and Start MM on a schedule:
not sure yet if pm2 is working in cron?
has to be run as user that stored the config,. when pm2 save is done
cause that info is store in the users .pm2 folder, ~/.pm2so if the cron job runs as user… oops…
so you might be able to use this, a trick I have in another app…
user=????username???? sudo -u $user pm2 start app_name or number
this lets you sneak into user mode for one command
so my username is sam,
for example, stop my mm appsudo -u sam pm2 stop 7
-
@sdetweil
I think adding the user pi /home/pi/pm2 stop all
worked but I am using your update script right now.
So not sure which one stopped MagicMirror.
The dang mouse arrow is on the screen, so I will have to find that command to hide it now… -
@plainbroke for the mouse pounter, install unclutter, have to reboot after, sometime
sudo apt install unclutter
but it SHOULD have been hidden already
pm2 status
will show you the apps
pm2 --help
will show you all it can do (a lot!)
yes, my upgrade script stops MM under pm2…