Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I put this file in /etc/init/proxyserver.conf that execute this script at startup (Ubuntu 11.10):

description "Run code for ProxyServer"
start on runlevel [23]

script
    cd /home/mark/selenium-client
    exec java -jar selenium-server-standalone-2.20.0.jar -role hub -port 1111
end script

This works fine but if I execute this in the terminal:

ps aux | grep selenium

It return this screen:

root  783   0.0   2.3  680584   23688   ?   Ssl   Apr18   4:45   java -jar selenium-server-standalone-2.20.0.jar -role hub -port 1111

But I want to run the script as non-root user, how I can do this?

Thanks!

share|improve this question
add comment

3 Answers

You could run it in crontab with the @reboot option

crontab -e to open up the user crontab.

add the line @reboot /path/to/script and it should start up your script on reboot as that user

Some more examples of cron use here

share|improve this answer
add comment

In Upstart, use the setuid keyword:

description "Run code for ProxyServer"
start on runlevel [23]

setuid mark
chdir /home/mark/selenium-client
exec java -jar selenium-server-standalone-2.20.0.jar -role hub -port 1111

(script is unnecessary.)

Alternatively, create a user job instead of a system one.

share|improve this answer
add comment

You could use e.g.

sudo -u mark exec java -jar selenium-server-standalone-2.20.0.jar -role hub -port 1111

to use the root privileges to execute the process as a specified user.


EDIT: Or perhaps

exec sudo -u mark java -jar selenium-server-standalone-2.20.0.jar -role hub -port 1111

depending on what upstart wants (I don't use it myself).

share|improve this answer
add comment

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.