jordi1206
Posts: 3
Joined: Tue Oct 22, 2013 7:56 pm

Autostart

Tue Oct 22, 2013 8:02 pm

Hello people,

Today I stared using http://www.pocketmine.net/.
That's a script which allows you to host a minecraft server.

I have one problem, to start it I need to run "#bash start.sh" using SSH on my pc.
But when I shut down my pc, also putty closes.

Does anyone know if I a raspberry can autorun "#bash start.sh" on boot?

Thanks for the help! :D

User avatar
DeeJay
Posts: 2027
Joined: Tue Jan 01, 2013 9:33 pm
Location: East Midlands, UK

Re: Autostart

Wed Oct 23, 2013 8:48 am

jordi1206 wrote:Does anyone know if I a raspberry can autorun "#bash start.sh" on boot?
Yes.

A Google search for "raspberry bash autostart" gives plenty of hits.

The first two I saw were -
http://www.raspberry-projects.com/pi/pi ... an/scripts

http://www.akeric.com/blog/?p=1976

Both seem to have useful advice.
How To Ask Questions The Smart Way: http://www.catb.org/~esr/faqs/smart-questions.html
How to Report Bugs Effectively: http://www.chiark.greenend.org.uk/~sgtatham/bugs.html

wimble
Posts: 34
Joined: Tue Feb 05, 2013 9:52 am

Re: Autostart

Wed Oct 23, 2013 9:28 am

The nohup (abbreviated from it's purpose: "No Hang UP") command is your friend, if you want to run commands and then log out.

so:

Code: Select all

nohup bash start.sh
and then log out, and the script will keep running. (Or you can use this for any other long running command.)

Another option is the screen utility.
If you run

Code: Select all

screen
from the command line, then after the obligatory informational messages (just press return to end), you'll be given a perfectly normal prompt. Run

Code: Select all

bash start.sh
as you normally would, and then, enter ctrl-A D (ie. hold down control. type A, release control, type D) to disconnect from screen, and get back to your normal prompt where you can log out. Once you've disconnected from screen, you can reconnect to it by invoking

Code: Select all

screen -r
, and you'll be back in your previous session, which will have been merrily running in your absence, but any output will have scrolled up the screen, and you'll be able to see exactly what's going on. Again, great for long running commands, where there's some degree of interaction (eg. it's actually an editor session, or you want to be able to see progress logs scrolling past).


Figuring out how to make it autostart when you boot the pi may be a better solution, depending on whether it's a dedicated minecraft server, or whether you only want to run it when it's convenient for you. It's certainly got the advantage that, once you've done it, you won't have to worry about it again ;)

Return to “Beginners”