MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    cron job hdmi on and off

    Scheduled Pinned Locked Moved Solved Troubleshooting
    29 Posts 4 Posters 4.0k Views 4 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S Offline
      Sam 0
      last edited by

      Re: [Cron Job Question](/tI used a cron job to turn my screen off and on I still want to do this I understand that the addressing of the monitor has changed and now only the code below works:

      Turn off display Sunday - Thursday at 22:00

      00 22 * ​​* 0-4 wlr-randr --output HDMI-A-1 --off

      Turn off display Friday - Saturday at 22:45

      45 22 * ​​* 5,6 wlr-randr --output HDMI-A-1 --off

      Turn on screen Monday - Friday at 7:00

      00 07 * * 1-5 wlr-randr --output HDMI-A-1 --on

      Turn on screen Saturday - Sunday at 8:00

      00 08 * * 6,0 wlr-randr --output HDMI-A-1 --onopic/16967/cron-job-question)
      05080d0a-5b0b-4960-8a96-64aef0a9f548-image.png

      i see that running the commands:
      wlr-randr --output HDMI-A-1 --off
      wlr-randr --output HDMI-A-1 --on
      works fine
      only putting this in cron and making it work didn’t work. i think i need to point the above cron job to files to have it run by cronjob can someone give a good example of what this looks like

      mumblebajM S 3 Replies Last reply Reply Quote 0
      • S Offline
        Sam 0
        last edited by

        ok is this good now? :) let me know the result tomorrow…

        677dcde8-ec68-4ede-8705-41e842eb790c-image.png

        7504475c-a69b-45c2-a5fb-e1d57751b929-image.png

        S 1 Reply Last reply Reply Quote 0
        • mumblebajM Offline
          mumblebaj Module Developer @Sam 0
          last edited by

          @Sam-0 Have a look at my post about this.

          https://forum.magicmirror.builders/topic/19116/having-trouble-with-screen-on-and-off-here-are-some-tips-that-could-help?_=1743776945326

          Check out my modules at: https://github.com/mumblebaj?tab=repositories
          Check my blog-post: https://mumblebaj.xyz/

          1 Reply Last reply Reply Quote 1
          • S Offline
            Sam 0 @Sam 0
            last edited by

            @Sam-0 thanks I will test it and share the result with you

            1 Reply Last reply Reply Quote 0
            • S Offline
              Sam 0 @Sam 0
              last edited by

              i created two files
              off.sh and on.sh
              they contain the following lines

              wlr-randr --output HDMI-A-1 --off
              wlr-randr --output HDMI-A-1 --on

              i also created a folder
              with the following rights:
              cmod 777
              the cron contains the following lines:
              unfortunately this does not work what is wrong?

              # Schakel display uit zondag - donderdag om 22.00
              00 22 * * 0-4 /home/username/MagicMirror/config/hdmionoff/off.sh>> /home/username/MagicMirror/config/hdmionoff/mof.log 2>&1
              # Schakel display uit vrijdag - zaterdag om 22.45
              45 22 * * 5,6 /home/username/MagicMirror/config/hdmionoff/off.sh>> /home/username/MagicMirror/config/hdmionoff/mof.log 2>&1
              # Zet het scherm aan maandag - vrijdag om 7u00
              00 07 * * 1-5/home/username/MagicMirror/config/hdmionoff/on.sh>> /home/username/MagicMirror/config/hdmionoff/mon.log 2>&1
              # Zet het scherm aan zaterdag - zondag om 8u00
              00 08 * * 6,0/home/username/MagicMirror/config/hdmionoff/on.sh>> /home/username/MagicMirror/config/hdmionoff/mon.log 2>&1
              
              S S evroomE 3 Replies Last reply Reply Quote 0
              • S Offline
                sdetweil @Sam 0
                last edited by

                @Sam-0 are the sh files marked executable?

                ls -laF in your folder to see

                permissions are 3 groups of 3 settings
                read/write/execute
                for user, group and all others
                9 settings from the right
                one more for directory and 1 for system

                ds, user, group, other

                Sam

                How to add modules

                learning how to use browser developers window for css changes

                1 Reply Last reply Reply Quote 0
                • S Offline
                  Sam 0 @Sam 0
                  last edited by

                  I thought it was right but now the rights on the sh files are set to 0777 and also on the folders
                  I also did a test to see if I could execute the sh files, this works tonight the cron should execute it, let me know if it works

                  7d588f38-160b-4f84-a7fc-6932e1d74561-image.png

                  S 1 Reply Last reply Reply Quote 0
                  • S Offline
                    sdetweil @Sam 0
                    last edited by sdetweil

                    @Sam-0 yes. although you dont need write permission, (except for user)
                    means anyone else could change the script

                    Sam

                    How to add modules

                    learning how to use browser developers window for css changes

                    S 1 Reply Last reply Reply Quote 0
                    • evroomE Offline
                      evroom @Sam 0
                      last edited by evroom

                      @Sam-0 said in cron job hdmi on and off:

                      i created two files
                      off.sh and on.sh
                      they contain the following lines

                      wlr-randr --output HDMI-A-1 --off
                      wlr-randr --output HDMI-A-1 --on

                      Do you have #!/bin/bash or #!/bin/sh at the very beginning of your shell scripts ?

                      #! /bin/sh – Execute the file using the Bourne shell, or a compatible shell, assumed to be in the /bin directory
                      #! /bin/bash – Execute the file using the Bash shell

                      You can also put /bin/bash in the crontab entry (before /home/username/...).
                      Then there is no way for cron to not execute it as a shell script and it will even run without the executable bit set.

                      And what Sam mentioned: the scripts need to be executable but not necessarily writable (chmod 755).
                      This should normally do the trick.

                      If you have mail installed (which mail) you can put this at the very beginning of the crontab file:
                      MAILTO=username (in my case admin).
                      With
                      journalctl --since "1 day ago" --unit cron.service --no-pager
                      you can see if cron ran your script and with mail you can see more details on the cron job executed.

                      Good luck.

                      MagicMirror version: 2.30.0
                      Raspberry Pi 4 Model B Rev 1.5 (8 GB RAM)
                      Raspbian GNU/Linux 12 (bookworm)

                      Test environment:
                      MagicMirror version: v2.30.0
                      Raspberry Pi 3 Model B Plus Rev 1.3 (1 GB RAM)
                      Raspbian GNU/Linux 12 (bookworm)

                      1 Reply Last reply Reply Quote -1
                      • S Offline
                        Sam 0 @sdetweil
                        last edited by sdetweil

                        @evroom Thanks for your explanation, I have made adjustments and will check tonight if it works. I will report this back. Thanks for the effort.

                        1 Reply Last reply Reply Quote 0
                        • S Offline
                          Sam 0
                          last edited by

                          unfortunately it still doesn’t work what am I doing

                          wrong?!

                          6df4646c-2d05-4f37-ab98-06602edb7242-image.png
                          cron info

                          on sh file
                          5579a93f-27f3-4e53-b75e-59c5306798b8-image.png

                          off sh file
                          e7e6712a-47f1-4210-b91f-6eb6bc5c7230-image.png

                          error logfile:
                          2d8cad2e-a6e6-496d-a3eb-34dfff1f115d-image.png

                          evroomE 3 Replies Last reply Reply Quote 0
                          • 1
                          • 2
                          • 3
                          • 1 / 3
                          • First post
                            Last post
                          Enjoying MagicMirror? Please consider a donation!
                          MagicMirror created by Michael Teeuw.
                          Forum managed by Sam, technical setup by Karsten.
                          This forum is using NodeBB as its core | Contributors
                          Contact | Privacy Policy