RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login
    Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

    How to restart ES from a script?

    Scheduled Pinned Locked Moved Help and Support
    scriptessystems.cfgrestart
    111 Posts 5 Posters 42.8k Views
    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.
    • BuZzB
      BuZz administrators @cyperghost
      last edited by BuZz

      @cyperghost I'm not sure what the problem is ? :)

      [edit] is it still the same issue as in the OP ? I'd have to test, but it should be ok to killall on ES, which would also kill the current running script of course as it's a child process itself.

      To help us help you - please make sure you read the sticky topics before posting - https://retropie.org.uk/forum/topic/3/read-this-first

      cyperghostC 1 Reply Last reply Reply Quote 0
      • cyperghostC
        cyperghost @BuZz
        last edited by

        @BuZz ... and you ask me? :D

        Bild Text

        TMNTturtlguyT cyperghostC 2 Replies Last reply Reply Quote 0
        • TMNTturtlguyT
          TMNTturtlguy @cyperghost
          last edited by

          @cyperghost @meleu

          That did it! Success....I am now back to running without getting the errors. @cyperghost your script does work well. I am going to upload the update to github. If you are willing it would be great for you to test. It is easy for you to delete the script after testing if you don't find it useful. Thanks for all the help. Will be interested to see how updates to ES will affect this.

          1 Reply Last reply Reply Quote 0
          • cyperghostC
            cyperghost @cyperghost
            last edited by cyperghost

            @BuZz
            The problem is that you can't kill ES with killall command.
            It will return to bash prompt and you are not able to restart in graphical mode on your TV (via SSH yes that works)

            So I seem to kill the latest child process that forces ES to restart IF a es-restart is present in /tmp

            meleus script kills two pids... and then ES is gone like killall.

            Maybe now you understand my "EUREKA" ;)

            BuZzB 1 Reply Last reply Reply Quote 0
            • BuZzB
              BuZz administrators @cyperghost
              last edited by

              @cyperghost perhaps he accidently killed the parent bash script. Killing all ES processes or just one shouldn't make a difference. I'll test though.

              To help us help you - please make sure you read the sticky topics before posting - https://retropie.org.uk/forum/topic/3/read-this-first

              1 Reply Last reply Reply Quote 0
              • cyperghostC
                cyperghost
                last edited by

                @BuZz
                Please test... maybe you understand my EUREKA today, okay?
                This was really tricky

                BuZzB 1 Reply Last reply Reply Quote 0
                • meleuM
                  meleu
                  last edited by

                  @cyperghost @TMNTturtlguy
                  Some background I would like to share with you guys:

                  • when you type emulationstation in the shell, it executes /usr/bin/emulationstation

                  • the /usr/bin/emulationstation is a shell script that calls /opt/retropie/supplementary/emulationstation/emulationstation.sh.

                  • the /opt/retropie/supplementary/emulationstation/emulationstation.sh calls the /opt/retropie/supplementary/emulationstation/emulationstation and this is the real emulationstation binary.

                  • the /opt/retropie/supplementary/emulationstation/emulationstation.sh has a logic to restart ES, restart system and shutdown system based on the existence of some specific files in /tmp. The code of this script can be seen here.

                  • in my failed attempt to restart ES from commandline, I was trying create the /tmp/es-restart and kill only the ES binary. According to the emulationstation.sh it's enough to restart ES. But as we saw, my approach is killing the emulationstation.sh too, and that is what is "crashing".

                  I'll try something more concise this evening, but if @cyperghost has some free time now and would like to investigate more, my suggestion is to find a way to kill only that very specific binary: /opt/retropie/supplementary/emulationstation/emulationstation.

                  I used those metacharacters on my pkill regex to try to match some edge cases (like running a custom branch ES or launching ES with some parameter).

                  P.S.: now that I see @BuZz is aboard, I'm sure that the elegant solution is coming. :)

                  • Useful topics
                  • joystick-selection tool
                  • rpie-art tool
                  • achievements I made
                  1 Reply Last reply Reply Quote 2
                  • BuZzB
                    BuZz administrators @cyperghost
                    last edited by BuZz

                    @cyperghost I think the problem is just the emulationstation.sh is being killed (which handles the restarting). Should be simple enough to avoid killing that. eg specifying the process name exactly rather than pattern matching.

                    To help us help you - please make sure you read the sticky topics before posting - https://retropie.org.uk/forum/topic/3/read-this-first

                    cyperghostC 1 Reply Last reply Reply Quote 0
                    • cyperghostC
                      cyperghost @BuZz
                      last edited by cyperghost

                      @BuZz Please go on.... I think it is not as easy
                      Because I manually lauched /opt.../ emulationstation.sh and that did not workd.
                      @TMNTturtlguy discovered the /tmp thing today +1 for him

                      BuZzB 1 Reply Last reply Reply Quote 1
                      • BuZzB
                        BuZz administrators @cyperghost
                        last edited by BuZz

                        @cyperghost It should be. I would guess at something like

                        touch /tmp/es-restart; killall -e "/opt/retropie/supplementary/emulationstation/emulationstation"
                        

                        should be fine.

                        To help us help you - please make sure you read the sticky topics before posting - https://retropie.org.uk/forum/topic/3/read-this-first

                        1 Reply Last reply Reply Quote 1
                        • cyperghostC
                          cyperghost
                          last edited by

                          let me test...

                          1 Reply Last reply Reply Quote 0
                          • BuZzB
                            BuZz administrators
                            last edited by BuZz

                            or to work with emulationstation running from any path. (eg with emulationstation-kids etc).

                            touch /tmp/es-restart; pkill -f "/emulationstation$"
                            

                            To help us help you - please make sure you read the sticky topics before posting - https://retropie.org.uk/forum/topic/3/read-this-first

                            cyperghostC 1 Reply Last reply Reply Quote 1
                            • cyperghostC
                              cyperghost
                              last edited by cyperghost

                              Works fine

                              touch /tmp/es-restart; killall -e "/opt/retropie/supplementary/emulationstation/emulationstation"
                              
                              1 Reply Last reply Reply Quote 0
                              • cyperghostC
                                cyperghost @BuZz
                                last edited by cyperghost

                                @BuZz said in How to restart ES from a script?:

                                pkill -f "/emulationstation$"

                                That let's restart just 2 PIDs... Does not work!

                                touch /tmp/es-restart; killall -e "/opt/retropie/supplementary/emulationstation/emulationstation"
                                

                                runs fine all 3 PIDs are up to date


                                Man ... I even wrote use the tty1 outputs. So indeed the relauch script was killed

                                BuZzB TMNTturtlguyT 2 Replies Last reply Reply Quote 0
                                • BuZzB
                                  BuZz administrators @cyperghost
                                  last edited by

                                  @cyperghost said in How to restart ES from a script?:

                                  pkill -f "/emulationstation$"

                                  Worked here when I just tested.

                                  To help us help you - please make sure you read the sticky topics before posting - https://retropie.org.uk/forum/topic/3/read-this-first

                                  cyperghostC 1 Reply Last reply Reply Quote 1
                                  • cyperghostC
                                    cyperghost @BuZz
                                    last edited by cyperghost

                                    @BuZz Wait I post output in a few minutes...

                                    pi@retropie:~ $ ls /tmp
                                    es-restart  omxplayerdbus.root  omxplayerdbus.root.pid
                                    pi@retropie:~ $ ps -a
                                      PID TTY          TIME CMD
                                      862 tty1     00:00:00 bash
                                      867 tty1     00:00:00 bash
                                      868 tty1     00:00:00 emulationstatio
                                      874 tty1     00:00:00 emulationstatio
                                      877 tty1     00:00:13 emulationstatio
                                      990 pts/0    00:00:00 ps
                                    

                                    The command pkill

                                    pi@retropie:~ $ pkill -f -e "/emulationstation$"
                                    emulationstatio killed (pid 868)
                                    emulationstatio killed (pid 877)
                                    

                                    check with ps -a

                                    pi@retropie:~ $ ps -a
                                      PID TTY          TIME CMD
                                      862 tty1     00:00:00 bash
                                      874 tty1     00:00:00 emulationstatio
                                     1001 tty1     00:00:08 emulationstatio
                                     1071 pts/0    00:00:00 ps
                                    

                                    worked now... sorry... but 2 PIDs alive
                                    If PID 874 in my current setup will be killed than ES is wrecked.

                                    Thank you

                                    BuZzB 1 Reply Last reply Reply Quote 0
                                    • BuZzB
                                      BuZz administrators @cyperghost
                                      last edited by BuZz

                                      @cyperghost use ps -fa as you can't tell what they are from that. probably parent bash scripts (which is correct - they shouldn't be killed).

                                      To help us help you - please make sure you read the sticky topics before posting - https://retropie.org.uk/forum/topic/3/read-this-first

                                      1 Reply Last reply Reply Quote 1
                                      • TMNTturtlguyT
                                        TMNTturtlguy @cyperghost
                                        last edited by

                                        @BuZz @cyperghost

                                        touch /tmp/es-restart; killall -e "/opt/retropie/supplementary/emulationstation/emulationstation"

                                        runs fine all 3 PIDs are up to date

                                        When i use this in my script, it runs the first time. The second time i try to run it, the script crashes with error "cant remove /tmp/es-restart

                                        cyperghostC BuZzB 2 Replies Last reply Reply Quote 0
                                        • cyperghostC
                                          cyperghost
                                          last edited by

                                          @BuZz
                                          Thank you I will remember that command!
                                          Very usefull :)

                                          1 Reply Last reply Reply Quote 0
                                          • cyperghostC
                                            cyperghost @TMNTturtlguy
                                            last edited by cyperghost

                                            @TMNTturtlguy I will check....
                                            I tested all scripts 2 two 3 times... all runing fine

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.

                                            Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.