Solved

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

Posted on 2013-11-22
4
676 Views
Last Modified: 2013-11-29
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
0
Comment
Question by:97WideGlide
  • 2
4 Comments
 
LVL 19

Accepted Solution

by:
xterm earned 500 total points
Comment Utility
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
 
LVL 19

Expert Comment

by:xterm
Comment Utility
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
 
LVL 20

Expert Comment

by:tfewster
Comment Utility
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
 
LVL 8

Author Closing Comment

by:97WideGlide
Comment Utility
Thank you.  This solution worked well for me.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now