

- #Systemctl enable xscreensaver install
- #Systemctl enable xscreensaver upgrade
- #Systemctl enable xscreensaver full
To check the status of Magic Mirror sudo systemctl status rvice

Stop MM with systemctl sudo systemctl stop rvice Note: For any of the below commands ‘rvice can be replaced withmagicmirror as systemd will automatically look for*.service` Start MM with systemctl sudo systemctl start rvice If MM does not start, use the “status” command below to see most recent errors. If start is successful work, use the ‘enable’ command below to automatically start when MM fails or is rebooted. Now try starting MM with the commands below. WorkingDirectory=/home/server/MagicMirror/ “root” will certainly work but has the potential to do more damage, so you should avoid it if possible. This example also assumes you have an existing Linux user of “server”, but any user will do.
#Systemctl enable xscreensaver full
While you almost certainly don’t type this all out when you run manually, systemctl requires full paths.
#Systemctl enable xscreensaver install
Notes: The example assumes your Magic Mirror is installed in the “WorkingDirectory” of “/home/server/MagicMirror/” and your node install is located at “/usr/bin/node” (run which node if you’re unsure where to find node) this means your full manual start command would be “/usr/bin/node /home/server/MagicMirror/serveronly”. Place the below text into your new file, modify as needed (see notes below) then save & exit. To start, you’ll need to create a config file via your editor of choice (nano used in these examples): sudo nano /etc/systemd/system/rvice This approach is most like only applicable for those using the “server only” setup running on a linux server. Note: Systemctl is a control interface for systemd, a powerful service manager often found in full Linux systems. With your MagicMirror running via PM2, you have some handy tools at hand: Restarting your MagicMirror pm2 restart mm Stopping your MagicMirror pm2 stop mm Show the MagicMirror logs pm2 logs mm Show the MagicMirror process information pm2 show mm Using systemd/systemctl To do this, execute the following command pm2 saveĪnd that’s all there is! You MagicMirror should now reboot after start, and restart after any failure. To make sure the MagicMirror restarts after rebooting, you need to save the current state of all scripts running via PM2. Enable restarting of the MagicMirror script. You mirror should now boot up and appear on your screen after a few seconds. Simply start your mirror with the following command: pm2 start mm.sh You are now ready to the MagicMirror using this script using PM2.

Now make sure the shell script is executable by performing the following command: chmod +x mm.sh Save and close, using the commands CTRL-O and CTRL-X.
#Systemctl enable xscreensaver upgrade
Preferable, we put this script outside the MagicMirror folder to make sure it won’t give us any issues if we want to upgrade the mirror. To use PM2 in combination with MagicMirror, we need to make a simple shell script. PM2 will now show you a command you need to execute.

Luckily, PM2 has a handy helper for this. To make sure PM2 can do it’s job when (re)booting your operating system, it needs to be started on boot. Install PM2 using NPM: sudo npm install -g pm2 In this case we will use it to keep a shell script running. It allows you to keep applications alive forever, to reload them without downtime and to facilitate common system admin tasks. PM2 is a production process manager for Node.js applications with a built-in load balancer. The methods below describe ways to automatically start your MagicMirror2 on boot, and even ways to keep it running in case of a failure.
