Super User is a question and answer site for computer enthusiasts and power users. 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 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
    
How about using su to run it as whatever user you want. You still would need root to set that up tho i think – B T May 22 at 1:57

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

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

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

You must log in to answer this question.

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