MagicMirror² v2.13.0 is available! For more information about this release, check out this topic.

Cronjob


  • Project Sponsor

    Good evening

    I’d like to see my MagicMirror restart at a certain time each day. What should I enter in the crontrab? I have already tried x variants, but unfortunately it never worked.

    27 17 * * * Command pm2 restart mm
    

    The sudo reboot command works fine.

    27 17 * * 5 sudo poweroff
    

  • Project Sponsor

    @CyruS1337 said in Cronjob:

    Good evening

    I’d like to see my MagicMirror restart at a certain time each day. What should I enter in the crontrab? I have already tried x variants, but unfortunately it never worked.

    27 17 * * * Command pm2 restart mm
    

    The sudo reboot command works fine.

    27 17 * * 5 sudo poweroff
    

    Did you forget to write the full command? Try pm2 restart mm.sh
    By the way: I prefere the online crontab generator (https://crontab-generator.org/). It’s very easy.
    Regards Mike


  • Project Sponsor

    Thanks for the link, but it still does not work 😞

    # Edit this file to introduce tasks to be run by cron.
    #
    # Each task to run has to be defined through a single line
    # indicating with different fields when the task will be run
    # and what command to run for the task
    #
    # To define the time you can provide concrete values for
    # minute (m), hour (h), day of month (dom), month (mon),
    # and day of week (dow) or use '*' in these fields (for 'any').#
    # Notice that tasks will be started based on the cron's system
    # daemon's notion of time and timezones.
    #
    # Output of the crontab jobs (including errors) is sent through
    # email to the user the crontab file belongs to (unless redirected).
    #
    # For example, you can run a backup of all your user accounts
    # at 5 a.m every week with:
    # 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
    #
    # For more information see the manual pages of crontab(5) and cron(8)
    #
    # m h  dom mon dow   command
    #
    #MONTAG BIS SONNTAG UM 19:55 MAGICMIRROR RESTART
    55 19 * * * pm2 restart mm.sh >/dev/null 2>&1
    #
    #SAMSTAG REBOOT UM 12:00 MAGICMIRROR REBOOT
    24 17 * * * sudo reboot
    #
    

  • Project Sponsor

    @CyruS1337 said in Cronjob:

    Thanks for the link, but it still does not work 😞

    # Edit this file to introduce tasks to be run by cron.
    #
    # Each task to run has to be defined through a single line
    # indicating with different fields when the task will be run
    # and what command to run for the task
    #
    # To define the time you can provide concrete values for
    # minute (m), hour (h), day of month (dom), month (mon),
    # and day of week (dow) or use '*' in these fields (for 'any').#
    # Notice that tasks will be started based on the cron's system
    # daemon's notion of time and timezones.
    #
    # Output of the crontab jobs (including errors) is sent through
    # email to the user the crontab file belongs to (unless redirected).
    #
    # For example, you can run a backup of all your user accounts
    # at 5 a.m every week with:
    # 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
    #
    # For more information see the manual pages of crontab(5) and cron(8)
    #
    # m h  dom mon dow   command
    #
    #MONTAG BIS SONNTAG UM 19:55 MAGICMIRROR RESTART
    55 19 * * * pm2 restart mm.sh >/dev/null 2>&1
    #
    #SAMSTAG REBOOT UM 12:00 MAGICMIRROR REBOOT
    24 17 * * * sudo reboot
    #
    

    Sounds strange. Maybe you first have to stop the pm2 process before restart, with pm2 stop mm.sh. Don’t forget to complete the line für den reboot am Samstag - sudo reboot >/dev/null 2>&1
    regards Michael



  • Why do you want to restart MM? Maybe pm2 reload mmis the better option.


  • Project Sponsor

    @MadScientist said in Cronjob:

    Why do you want to restart MM? Maybe pm2 reload mmis the better option.

    Why … that’s actually a good question. The problem is that if I bring the screens for about 5-6 hours and then turn back on that no picture appears on the monitors. Therefore, I would like a regular restart of my MagicMirros.



  • Are you using the GoogleMapsTraffic module? In that case the pm2 reload mm will do. Or a simple Ctrl+R on the mirror. The cronjob should then look something like 55 19 * * * pm2 reload mm (mine is 0 6 * * * pm2 reload mm and it works flawlessly).


  • Project Sponsor

    @MadScientist said in Cronjob:

    Are you using the GoogleMapsTraffic module? In that case the pm2 reload mm will do. Or a simple Ctrl+R on the mirror. The cronjob should then look something like 55 19 * * * pm2 reload mm (mine is 0 6 * * * pm2 reload mm and it works flawlessly).

    Exactly, I use the modules GoogleMapsTraffi on these two monitors and these two monitors will not wake up after a while, if I turned off the monitors for several hours.

    Then tonight I will try pm2 reload mm. Unfortunately, the command pm2 restart mm did not work. Then I’m curious.



  • Depennding on the other modules you’re using it might be good to reload MM more than once a day. In my case once is enough. Without reloading the screen turns black after more than one day. Depending on your setup it could be better to reload it twice or 4 times a day. In the end the reload is very quick and you won’t notice anything.


  • Project Sponsor

    Perfect, did not know that I can reload the MagicMirror. Have always made a restart in the past. I’ll give feedback this evening on whether the cronjob works with the pm2 reload mm command


Log in to reply