Server Fault is a question and answer site for system and network administrators. 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'm trying to run a command/service on startup with Upstart as a non-privileged user, while preserving /etc/environment.

I had some luck in a shell with

exec sudo -u user1 -i "/usr/bin/foo /opt/bar >> /var/log/bar.log 2>&1"

However, Upstart doesn't seem to like it (haven't been able to figure out why). I know the general advice is to use su and I had some success with that by manually sourcing a file like /etc/environment.local, but had problems getting Upstart to monitor the correct PID (it kept going after bash, instead of /usr/bin/foo, thus the attempt at sudo.

Any advice would be a huge help. I'm on Amazon Linux on EC2.

share|improve this question

Just source the /etc/environment file into your upstart script ?

if [ -e /etc/environment ]; then
    . /etc/environment
share|improve this answer

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.