I am planning to use inosync to sync data from master server to several client servers. I have created a user called rsyncuser in both master and slaves with access permissions and passwordless ssh access from master to slave servers.

Inosync is working when I use it from the command line as rsyncuser.

Next I want this to start automatically when server is turned on. I figured upstart is the way to get this working.

I am unable to find the right upstart command to get this working.

Here is my upstart conf file. The problem seems to be around running "inosync -d -c /etc/inosync/inosync_rsyncuser.py" as a given user.

As you can see I have tried a number of various options!

description     "start inosync to sync data to other CDN Servers as rsyncuser"
console output
#start on startup
#stop on shutdown
start on (net-device-up and local-filesystems)
stop on runlevel [016]

#start on runlevel [2345]
#stop on runlevel [!2345]
#kill timeout 30
env RUN_AS_USER=rsyncuser

expect fork

   echo "Inosync updtart job seems to have started" >> /tmp/upstart.log
#   exec sudo -u rsyncuser -c "ls -la" >> /tmp/upstart.log 2>&1
#   LOGFILE=/var/log/logfile.`date +%Y-%m-%d`.log

#   exec su - $RUN_AS_USER -c "inosync -d -c /etc/inosync/inosync_rsyncuser.py" >> $LOGFILE 2>&1
#  exec  su -c "ls -la" >> /tmp/upstart.log 2>&1
#   emit inosync_running
end script

1 Answer 1


sudo by default stomps on most of the environment. Try this (adding -E):

exec sudo -E -u rsyncuser -c "ls -la" >> /tmp/upstart.log 2>&1

-E tells sudo to preserve the environment.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.