UbuntuOne u1sdtool sync daemon to start at boot on headless Ubuntu server

Hi,
We have a headless Ubuntu (12.04.1 LTS) server where our files are synced every night at 11:00PM to storage on UbuntuOne using the u1sdtool daemon. It works perfectly but we have to start the daemon manually each time the server is restarted.
It seems the best way to get it running would be by modifying the /etc/init scripts and we tried that but it doesn't seem to work.  As a stopgap measure we made the following entry to User curt's crontab file but it doesn't work either:

30 22 * * * /home/curt/bin/u1sdtool --connect 2>&1 >> /home/curt/log/u1sdtool.log

This command, when run manually from the 'curt' account works just fine.

It would be awesome if anyone could please provide the recommended way to add u1sdtool to the /etc/init Upstart system.

In the alternative, a better way to start or make sure u1sdtool is running (maybe through Cron) each day would be good too....

Thanks,
Curt
LVL 8
97WideGlideAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
xtermConnect With a Mentor Commented:
Your cron is set up to run at 10:30PM each night - not sure what "doesn't work" means, but if the cron generated an error, it would've sent an email which you can find in /var/spool/mail/curt, and it would contain the error output.

Regardless, the easiest way to start this is to do it from /etc/rc.local  Keep in mind that this file is executed as root though, so you will want it to su to user curt in order to run as a user as intended.

So add these 2 lines to the end of /etc/rc.local:

# Start up sync daemon
su curt -c "/home/curt/bin/u1sdtool --connect 2>&1 >> /home/curt/log/u1sdtool.log"

Open in new window


This should work for you.  You can test it by running that command as root beforehand and making sure it works.
0
 
xtermCommented:
Or if you want to check each minute to make sure this process is running and start it if it's not, then you can use this little script:

#!/bin/sh

# Create this script as /usr/local/bin/check_u1sdtool.sh and run every minute in user curt's crontab using this entry
# without the pound sign in front
# * * * * * /usr/local/bin/check_u1sdtool.sh

RUNNING=`ps ax | grep -v grep | grep u1sdtool | wc -l`
if [ $RUNNING -eq 0 ]; then
        mail -s"u1sdtool not running - restarting" you@yourdomain.com </dev/null 1>/dev/null
        /home/curt/bin/u1sdtool --connect 2>&1 >> /home/curt/log/u1sdtool.log
fi

Open in new window

0
 
tfewsterCommented:
A common problem with starting processes at boot time or via cron is that they will be executed in a minimal environment - try comparing the output of the `env` command as root and as user "curt". It's often the PATH, but could be any environment variable the "u1sdtool" daemon expects. I suspect it's the "~/.config/ubuntuone" and "~/bin" directories it can't find, and setting "PATH=$HOME:$HOME/bin:$PATH" may fix it.

That said, I'd expect your log file to give you a clue as to why the process was failing.

If something isn't getting set, there are a number of workarounds - Explicitly set a variable, dot-in your .profile (or whichever of your startup files sets the variable), or use `su -l curt <etc.>` to execute user curt's login scripts

More info on the required environment at
http://askubuntu.com/questions/95591/how-do-i-configure-ubuntu-one-on-a-server
or by searching the web for "u1sdtool environment"
0
 
97WideGlideAuthor Commented:
Thank you.  This solution worked well for me.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.