Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

G'day,

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

1 Answer 1

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

if [ -e /etc/environment ]; then
    . /etc/environment
fi
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.