Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to run a script once the server reboots. So, how can I change it. My script needs only one file to open and it opens in terminal. I read something about changing configurations or cronjobs, but how exactly to change it ? I want to do that because if I close the terminal obvious the script stops, so if I make it start on reboot it will work 24/7 I guess. What I do now is, open openssh, connect to my server, run the script, but when I close the session the script stops working, so I'm trying to make it permanently. Thanks!

Version: Ubuntu 10.04 LTS.

share|improve this question
up vote 3 down vote accepted

If you want to start it manual have a look at screen. First install it with sudo apt-get install screen. Then you can start a screen session with one screen -S NAME and you can deteach the session with ´Ctrl+A D´, so it remains after you closed your ssh session. With screen -r NAME you can reteach it, if you need to.

For an autostart, you can place your script in the file /etc/rc.local for a execution on every boot. But watch out, exit 0 must remain as last line. The commands in this file will be executed with root. If you don't want this, you can add a su USERNAME -c "COMMAND" If you want to acces it later, I prefer screen -dmS NAME COMMAND, so you can reteach it with screen -r COMMAND. In completion: su USERNAME -c "screen -dmS SESSIONNAME COMMAND"

share|improve this answer
Thanks man, you're awesome. Never know about that, it even existed as an app, lol. Thanks again! – maikati Jan 26 '13 at 9:14
You're welcome ;) I'm here to help – lub Jan 26 '13 at 9:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.