0

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.

Daniel
  • 1

1 Answers1

3

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

if [ -e /etc/environment ]; then
    . /etc/environment
fi
user9517
  • 114,104
  • 20
  • 206
  • 289