Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I need to run a script at startup, the script needs to run under a certain user, not as root, i tried adding the script to /etc/rc.local like this:

#!/bin/sh -e
#
# rc.local
#
#!/bin/sh
su - tue -c "/home/tue/main"
su - tue -c "/opt/craftbukkit/start.sh"

The first line starts a program main in /home/tue, this is working fine. The second line is my script, but for some reason this isn't being run?

share|improve this question

2 Answers 2

Take into account that:

  1. second command could only start when the first terminates (or go to background);

  2. -e option will stop the execution if a command returns a nonzero exit code.

share|improve this answer

Try something like this:

#!/bin/sh -e
#
# rc.local
#
#!/bin/sh
su - tue -c "/home/tue/main" &
su - tue -c "/opt/craftbukkit/start.sh" &

This will start both processes in the background, so that the rest of the script can continue normally. If this isn't what you want, please explain your situation more fully.

share|improve this answer

Your Answer

 
discard

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.