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 41.2k 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 @BuZz Ok, so I did the ps -a and killed the largest emulationstatio and i can at least navigate the menus again....so yes the pkill is causing the issue,

      Next issue is after the setup script update my script gives an error saying that '/opt/retropie/configs/all/emulationstation/es_systems.cfg' is write protected and the script errors out.

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

        @TMNTturtlguy if your script wants to edit that file it will need to use sudo as user scripts are no longer run as root.

        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

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

          @BuZz thanks that seems to work. New issue. When running

          touch /tmp/es-restart
          pkill -f "/opt/retropie/supplementary/.*/emulationstation$"
          

          the script works great, but when i press start and go to QUIT, the screen flashes back to my script and ES restarts. I can't navigate to exit or shutdown. I immediately see the script blue screen and restart ES. So this is not killing the /tmp/es-restart

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

            you can please check permission of your Restart Script in retropiemenu.
            It must be set to pi.

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

              @cyperghost another beginner questions, how do i check that?

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

                @TMNTturtlguy
                Because the sh und rp files are called via bash. I'm not 100% sure if this can cause errors. if you never entered SSH as root it's very unlikely you have the wrong permission set.

                Sorry late here
                ls -al in retropiemenue

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

                  @cyperghost everything is set to pi

                  0_1497635557803_4606aa25-3b6b-4ad2-8688-5af151cbaf51-image.png

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

                    @TMNTturtlguy @cyperghost @BuZz so i can confirm that

                    touch /tmp/es-restart
                    pkill -f "/opt/retropie/supplementary/.*/emulationstation$"
                    

                    Is still not killing all 3 PID. I had to go in and kill, when i did this i got the same blue screen with error text as i posted above using @meleu script. I just tried running this with sudo in front, same effect. Once it is run, entering into the start menu and the retropie menu causes me to immediately flash to the script screen and then restart ES.

                    0_1497636372023_bd659b45-2f90-46a2-ad7f-cacbc1e898e5-image.png

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

                      @TMNTturtlguy it's not supposed to kill all the processes - 2 are scripts to launch es which should be left running. Also see above regarding using ps so you can see the full names.

                      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

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

                        @BuZz
                        0_1497637196153_55b63908-f637-456f-a9fd-1d0caf1aab70-image.png

                        1 Reply Last reply Reply Quote 0
                        • TMNTturtlguyT
                          TMNTturtlguy
                          last edited by TMNTturtlguy

                          @BuZz @cyperghost when I killed 1162 from the above list, ES restated and now everything is functioning correctly. I then ran my script again, it worked, pressed start and went to menu, quit, and same thing occurs, a flash of my script menu and an restart of ES. This time i kill the highest number of ES, Es restarts and i get a message that /tmp/es-restart cannot be removed. Is this a permissions issue within the script? I am running the latest touch restart command from above with sudo now and it has no affect.

                          Edit: i added tried this:

                          touch /tmp/es-restart
                          pkill -f "/opt/retropie/supplementary/.*/emulationstation$"
                          sudo rm /tmp/es-restart
                          

                          This gets rid of the auto restart, but when I go to start, quit I can now select restart, when i do this it reruns the my script and defaults to the first option from my menu. I don't get the can't remove /tmp/es-restart message anymore. When i kill the largest number emulationstatio it exits to the same blue screen with weird text as posted above. The sudo rm /tmp/es-restart everything is back to normal again.

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

                            wazzup guys!

                            in front of my RetroPie it is a way easier! Here is my one liner to restart ES with no issues (at least it works fine here):

                            touch /tmp/es-restart && pkill -f "/opt/retropie/supplementary/.*/emulationstation([^.]|$)"
                            

                            Yes, the only difference is those / chars before and after .* in the regex. It's working fine thanks to this commit on RetroPie-Setup.

                            That one liner is able to restart ES even if the user is running a testing ES branch ( @TMNTturtlguy knows what I'm saying) and/or the user launched ES with some --arguments.

                            @TMNTturtlguy I hope it helps you.

                            Cheers!

                            • Useful topics
                            • joystick-selection tool
                            • rpie-art tool
                            • achievements I made
                            TMNTturtlguyT BuZzB 3 Replies Last reply Reply Quote 2
                            • TMNTturtlguyT
                              TMNTturtlguy @meleu
                              last edited by

                              @meleu thank you! Unfortunately we just left for a family weekend and I won't be home until Sunday evening. I will test it out right away. Thanks again! P.s. I brought my computer with to make your mame row logo! Will get that created and send you a download link!

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

                                I made a thread of all bash ideas oft the restart.
                                https://retropie.org.uk/forum/topic/11050/restart-es-via-bash-script/

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

                                  @meleu why "/opt/retropie/supplementary/.*/emulationstation([^.]|$)" rather than "/opt/retropie/supplementary/.*/emulationstation$" ? A use case I have missed ?

                                  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

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

                                    @BuZz yep. If the user launch emulationstation with some --argument the regex ending with emulationstation$ don't match. :-)

                                    Example: emulationstation --debug

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

                                      @meleu aha. Thanks. Didn't consider that.

                                      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 @meleu
                                        Changes are registered to Restart ES via batch thread
                                        added meleu as "slight" updater

                                        This was easy - wasn't it? EUREKA

                                        For @TMNTturtlguy what the difference between mine and @BuZz @meleu script.

                                        1. They doing all the same: killing one specific process

                                        but

                                        The script of meleu and BuZz
                                        specifies to kill all emulationstation scripts which can found in path "/opt/retropie/supplementary/"

                                        Mine just kills the latest call of any emulationstation call. That's the reason why I wrote ... Keep care of future updates of ES

                                        The the kind of "specification" makes the difference.

                                        Annother tipp for you: Every command has a help section ... just write --help as parameter
                                        If the program manis installed you can get more detailed help by man [command] for ex. man ls

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

                                          @cyperghost question for you,

                                          I am currently running the main branch EmulationStation updated from source. I have however run several different builds of emulationstation for testing out new updates of ES. As I am now running the main branch as updated from the setup script shouldn't I be running form /opt/supplementary/ ? Are you suggesting that because I have run the test branches when the main install of ES is killed by @BuZz and @meleu command another instance of ES from another location runs?

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

                                            @cyperghost

                                            The script of meleu and BuZz
                                            specifies to kill all emulationstation scripts which can found in path "/opt/retropie/supplementary/"

                                            This is not true. My last solution above kills only the "real" ES binary. Only one process. And don't do anything with the scripts.

                                            My solution is also able to kill/restart any of the ES mods we (I, @TMNTturtlguy and other guys) are testing. It's also able to kill emulationstation if it's launched with some --argument.

                                            I didn't analyze the solution proposed by @cyperghost to be able to give my opinion, but I'm pretty sure that my solution works pretty fine for what @TMNTturtlguy wants to do in the OP.

                                            • Useful topics
                                            • joystick-selection tool
                                            • rpie-art tool
                                            • achievements I made
                                            cyperghostC 1 Reply Last reply Reply Quote 1
                                            • 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.