1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

start.sh on startup

Discussion in 'Help' started by nematode, Apr 11, 2017.

  1. nematode

    nematode Spider

    Messages:
    8
    I'm new to linux (a few months). I have set up pocket minecraft server on a raspberry pi. The pi has no display and is permanently on beside our home router (static ip). I ssh to do everything on it. If I run the start.sh then close my ssh terminal, the process/server stops. So..... how do I get the start.sh to run all the time when the pi starts up?
     
  2. nematode

    nematode Spider

    Messages:
    8
    Never mind... I asked too quickly. More research found an answer.
     
    jasonwynn10 likes this.
  3. Awzaw

    Awzaw Zombie Pigman Poggit Admin

    Messages:
    726
    GitHub:
    awzaw
    The easy way is to use screen, the best way is to start PM as a service like this for example (untested):
     
    jasonwynn10 likes this.
  4. nematode

    nematode Spider

    Messages:
    8
    I used crontab. Is the screen a better option?
     
    jasonwynn10 likes this.
  5. Awzaw

    Awzaw Zombie Pigman Poggit Admin

    Messages:
    726
    GitHub:
    awzaw
    crontab is for scheduled tasks that repeat on a regular basis - screen is probably the best option for you as PM will keep running when you close your ssh session, and it's really easy to log back into the same screen session to continue where you left off.
     
    jasonwynn10 likes this.
  6. nematode

    nematode Spider

    Messages:
    8
    Ok, thank you. I'll change it to screen.
     
    jasonwynn10 likes this.
  7. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    what about TMUX? is that better then screen?
    some people says so
     
  8. Primus

    Primus Zombie Pigman

    Messages:
    749
    I guess TMUX is more advanced than screen. Rolex shows exact same time as my cheap wrist watch.
     
    corytortoise, Awzaw and HimbeersaftLP like this.
  9. TuxerP

    TuxerP Silverfish

    Messages:
    21
    Raspberry pi is based on debian jessie which uses systemd. You can run pocketmine as a systemd service with this script:
    -----start script-----
    [Unit]
    Description=PocketMine MineCraft Server

    [Service]
    User=pi
    ExecStart=/home/pi/pocketmine/start.sh 1>/dev/null 2>&1
    WorkingDirectory=/home/pi
    Restart=always
    RestartSec=5s

    [Install]
    WantedBy=multi-user.target
    -----end script-----

    Make sure you change the user and path to the ones on youre system.

    Put this script, everything between the "start script" and "end script" lines in this file and directory:
    /etc/systemd/system/pocketmine.service

    Execute this command to enable the service:
    sudo systemctl enable pocketmine

    And you can control pocketmine with these commands:

    sudo service pocketmine start
    sudo service pocketmine stop
    sudo service pocketmine restart
     
  10. Primus

    Primus Zombie Pigman

    Messages:
    749
    Seems nice, but what about I/O?
    Code:
    1>/dev/null 2>&1
    
     
  11. nematode

    nematode Spider

    Messages:
    8
    Right, update time. Awzaw, thanks for putting me onto screen. It seems the best solution for me to leave the server running and interact with it when I need to. It is also seems useful for other linux things. About a year ago I made the leap to linux for my whole family and it has been a learning curve. Sorry, this isn't a linux forum, its a minecraft one. Reading through this forum has enabled me to get a server up and running for one of my sons and HE LOVES IT! It's brilliant that we can play together, and then I can build when he is asleep, so he can see cool things in the morning. To be fair, I think they are cool. He just fills them with water, blows them up, or attacks me with zombies. Thank you all for your replies, and thank you for those who have posted in other threads which I have read.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.