ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    script running with cron

    IT Discussion
    cron ubuntu mate raspberry pi 3b+
    3
    13
    987
    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.
    • hobbit666H
      hobbit666 @marcinozga
      last edited by

      @marcinozga said in script running with cron:

      Add full path to notify-send and chromium-browser binaries and test again. Also your PATH variable is missing / after =

      Sorry typo on the post my script does have it 🙂

      1 Reply Last reply Reply Quote 0
      • hobbit666H
        hobbit666 @marcinozga
        last edited by

        @marcinozga said in script running with cron:

        Add full path to notify-send and chromium-browser binaries

        When I do a whereis notify-send I get:-

        /usr/bin/notify-send

        so just add that to the line?

        /usr/bin/notify-send Testing

        M 1 Reply Last reply Reply Quote 0
        • M
          marcinozga @hobbit666
          last edited by

          @hobbit666 yes.

          1 Reply Last reply Reply Quote 0
          • hobbit666H
            hobbit666
            last edited by

            Still no go.
            It's Friday 16:50 and i'm off home in 10 minutes so a job for Monday 😄

            1 Reply Last reply Reply Quote 0
            • hobbit666H
              hobbit666
              last edited by

              Still having Cron job issues.

              So ignore the script at the top. I've gone to basics:-

              This is the script located here /home/display1/chrome.sh
              (this has been created with nano chrome.sh NOT sudo)

              #!/bin/bash
              sleep 5
              pkill -o chromium
              sleep 10
              chromium-browser https://www.bbc.co.uk &
              sleep 5
              xdotool key F11
              

              ran chmod +x chrome.sh to add execute

              if I ./chrome.sh it runs and chrome opens.

              travisdh1T 1 Reply Last reply Reply Quote 0
              • hobbit666H
                hobbit666
                last edited by

                Now if I run crontab -e again no sudo (not sure if I should or not as the script will run with the user logged in

                
                15 15 * * * /home/display1/chrome.sh
                
                

                when that time comes nothing happens.

                1 Reply Last reply Reply Quote 0
                • travisdh1T
                  travisdh1 @hobbit666
                  last edited by

                  @hobbit666 said in script running with cron:

                  Still having Cron job issues.

                  So ignore the script at the top. I've gone to basics:-

                  This is the script located here /home/display1/chrome.sh
                  (this has been created with nano chrome.sh NOT sudo)

                  #!/bin/bash
                  sleep 5
                  pkill -o chromium
                  sleep 10
                  chromium-browser https://www.bbc.co.uk &
                  sleep 5
                  xdotool key F11
                  

                  ran chmod +x chrome.sh to add execute

                  if I ./chrome.sh it runs and chrome opens.

                  Add the full path for every command in the script. Use which $command to find any you don't know (I don't remember offhand where all these things live.)

                  1 Reply Last reply Reply Quote 0
                  • hobbit666H
                    hobbit666
                    last edited by

                    So I've added the following to the cron job

                    07 16 * * * /home/display1/chrome.sh > /home/display1/chrome.log 2>&1
                    

                    Also changed the chrome.sh to just 3 lines

                    #!/bin/bash
                    sleep 10
                    /usr/bin/chromium-browser
                    sleep 5
                    

                    So when it runs I look at the log file and see this:-
                    (Chromium-browser:3494): Gtk-WARNING **: 16:07:12.000: cannot open display:

                    travisdh1T 1 Reply Last reply Reply Quote 0
                    • travisdh1T
                      travisdh1 @hobbit666
                      last edited by

                      @hobbit666 said in script running with cron:

                      So I've added the following to the cron job

                      07 16 * * * /home/display1/chrome.sh > /home/display1/chrome.log 2>&1
                      

                      Also changed the chrome.sh to just 3 lines

                      #!/bin/bash
                      sleep 10
                      /usr/bin/chromium-browser
                      sleep 5
                      

                      So when it runs I look at the log file and see this:-
                      (Chromium-browser:3494): Gtk-WARNING **: 16:07:12.000: cannot open display:

                      Ah, there we go. The shell it's running as doesn't have a graphical environment setup. I forget offhand how I got around this because I so rarely have to. The only recent cases I've used fed to feed images to a screen.

                      hobbit666H 1 Reply Last reply Reply Quote 0
                      • hobbit666H
                        hobbit666 @travisdh1
                        last edited by

                        @travisdh1 Yeah think I may have found the solutions.
                        Will test and post back

                        1 Reply Last reply Reply Quote 1
                        • hobbit666H
                          hobbit666
                          last edited by

                          Looks like I needed to put

                          export DISPLAY=":0"

                          originally when I was trying it I didn't have the "

                          Now to test the whole script 😄

                          1 Reply Last reply Reply Quote 3
                          • 1 / 1
                          • First post
                            Last post