Solved

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

Posted on 2013-11-22
4
684 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
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.

770 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