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 40.1k 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.
    • TMNTturtlguyT
      TMNTturtlguy @cyperghost
      last edited by

      @cyperghost that is the thing, i don't have a /tmp/es-restart to delete, it isn't there! I am pretty confused, when i did my attempts running touch es-restart I always got a /tmp/ file. any issues, just sudo rm and it was fixed. Now i don't see a /tmp/es-restart file, however it is retaining the error screen from @meleu script.

      As you might be able to tell, i am not a coder, so i am really stretching here creating this stuff. It is fun, but there is a lot I don't understand. Can you provide more info on what you want me to do? Not sure what you mean by :

      Try this in shell output of ps -a
      in shell
      echo $(pgrep -l -n emulationstatio | awk '!/grep/ {printf "%s ",$1}')

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

        @TMNTturtlguy I'll sort it this evening, but when that happens with your terminal try to (maybe blindly) type reset and press enter.

        • Useful topics
        • joystick-selection tool
        • rpie-art tool
        • achievements I made
        1 Reply Last reply Reply Quote 0
        • cyperghostC
          cyperghost @TMNTturtlguy
          last edited by cyperghost

          @TMNTturtlguy
          connect via SSH
          in prompt type ps -a
          That list all process with tty1 output

          then create the file es-restart with sudo command
          sudo touch /tmp/es-restart

          check existance with
          ls /tmp

          into the ps list... take the pid from ES with the highst number (that's the latest processes) and type
          kill 1234 your PID here should not be 1234 ;)

          after that

          ps -a
          again... What do you see?

          meleuM TMNTturtlguyT 2 Replies Last reply Reply Quote 0
          • meleuM
            meleu @cyperghost
            last edited by

            @cyperghost maybe ps -a | grep emulationsta can give a cleaner output for him. :)

            • Useful topics
            • joystick-selection tool
            • rpie-art tool
            • achievements I made
            1 Reply Last reply Reply Quote 0
            • cyperghostC
              cyperghost
              last edited by cyperghost

              @meleu well that are only 2 or three more processes - clean enough but thank you ;)

              @TMNTturtlguy I'm also not a coder - I made my master degree in chemistry

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

                @cyperghost thanks for explaining!

                To answer your question from the previous post - OMX is the screensaver running, part of a new update to ES.

                here is my output - when i ran the kill line, it killed the screensaver.
                0_1497625746069_0f8ea24f-92e6-4002-b41f-13d774febe71-image.png

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

                  yes that's it...

                  You see so it works...
                  You killed ES with PID 941

                  This was terminated

                  and relaunched as new
                  ES with PID 1500

                  meleus script would kill
                  938 and 941
                  you can check with (the -e parameter shows list of killed PIDs)

                  pkill -f -e "/opt/retropie/supplementary.*emulationstation([^.]|$)"
                  

                  after meleus script all emulationstation PIDs are gone >> dead!

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

                    @cyperghost What's the problem with sending a SIGINT to all processes rather than one ?

                    @TMNTturtlguy es-restart will get removed by the ES launch script hence why it disappears.

                    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 Well ... You are the coding wizard :)

                      I think if you show us a way to solve this proper please go on.
                      Maybe you can make this waterproof? Or tell us something behind the scene of RetroPie?
                      Your are welcome!

                      BuZzB 1 Reply Last reply Reply Quote 0
                      • 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
                                            • 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.