Solved

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

Posted on 2013-11-22
4
682 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
ID: 39669991
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
ID: 39670017
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
ID: 39672318
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
ID: 39686205
Thank you.  This solution worked well for me.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Fine Tune your automatic Updates for Ubuntu / Debian
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

911 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

20 Experts available now in Live!

Get 1:1 Help Now