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.