1

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.

1 Answer 1

3

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"

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .