Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm using Debian 6 and Dropbox. I followed these commands to install it.

When I run ~/.dropbox-dist/dropboxd — Dropbox works and stuff. Problem is that when I close terminal or, even worse, — reboot... Dropbox stops to work and I need to run that deamon again.

Are there any way I say to computer to automatically start that daeamon in background?

share|improve this question
    
Have you tried the python script linked below on that same website? It seems to be targeted to controlling the daemon. (I don't have access to a debian-based machine ATM to try it myself though). –  Hugo Apr 3 '12 at 16:58
    
Thanks! I will try it. –  daGrevis Apr 3 '12 at 19:15
    
Perhaps nohup? unix.stackexchange.com/questions/56495/… –  njsg Feb 7 '13 at 14:43

10 Answers 10

up vote 24 down vote accepted

If you're running the daemon from your own account, start it at boot time with Cron. Run crontab -e to edit your crontab file and add the line

@reboot ~/.dropbox-dist/dropboxd
share|improve this answer
    
While this would work, ideally it would be best to create the service script within /etc/init.d/ utilizing the skeleton script that is contained within. You can then add the service dropbox start to the cron on reboot and still have the ability to stop the service and restart it. –  sparticvs Aug 14 '13 at 0:38
    
@sparticvs - Will dropbox not run as root if you put it in init.d? dropbox can be configured to run per user basis. Can the dropboxd be shared between users using different dropbox accounts? –  Lord Loh. Aug 16 '13 at 17:02
    
@LordLoh. good point. However you could change to who you want to run as. I did find this resource. Looks new. –  sparticvs Aug 16 '13 at 17:30
    
@LordLoh. @sparticvs I think there is a solution to the init.d running as root problem. I posted an answer of my own, but the solution at pixeldust.wikidot.com/linode-setup%3adropbox seems to work well. –  Zac Jan 9 at 20:31

You can find Debian and Ubuntu init.d scripts, just copy to /etc/init.d/dropbox and customize with user name.

Enable in debian with chkconfig --add dropbox. Then run as any other service.

share|improve this answer

There is a fairly nice way to add this to init.d described here. You have to add which users you want Dropbox to start for to the init script (easy enough), and when the system boots, it will start the Dropbox daemon for each of those users.

The only thing to note is that they specify DAEMON=.dropbox-dist/dropbox which I believe is incorrect. The author forgot the d at the end of that — it should be DAEMON=.dropbox-dist/dropboxd.

share|improve this answer

The solution is as other python programs :

shell$ nohup ~/.dropbox-dist/dropboxd & 
share|improve this answer

You could use screen:

screen -dmS ~/.dropbox-dist/dropboxd

This will start it as a daemon and in detached mode.

You would then have to write your own init.d script to have it run as service this way and add a line after #!/bin/bash for chkconfig and add the necessary run levels, such as 2, 3, 4, 5. Different distributions have different run levels so you'd have to check this.

share|improve this answer

You can also run as a daemon by doing daemon $HOME/.dropbox-dist/dropboxd.

This has the advantage that if you additionally pass the -n/--name flag, you can use daemon --[running|restart|stop] -n <name> to control the process.

Perhaps someone else can chip in on how best to get daemons started using daemon to run at startup...

share|improve this answer

Here is my solution for Linux distributions using Upstart 1.4 and higher.

Save the contents below into a configuration file under /etc/init, for example: /etc/init/db_user.conf

# Dropbox upstart script for user db_user, db_user can be replaced by anything you like.

description "Dropbox db_user"
author "myth384"

start on runlevel [2345]
stop on runlevel [!2345]

respawn

setuid db_user
# The next two lines are optional. I use these to be able to share the Dropbox using Samba. Within group shareusers are all Samba users.
# setgid shareusers
# umask 0002

# The next line is necessary to be able to synchronise files with non-ASCII characters.
env LANG="en_US.UTF-8" 

exec /home/db_user/.dropbox-dist/dropbox

To start up the daemon without rebooting:

sudo start db_user

Note: By uncommenting the setgid line it is not necessary to set the setgid flag on the .dropbox.cache folder as indicated by other sources on the internet.

share|improve this answer

I think the best way is to create a new file in /usr/bin with this code:

#!/bin/bash

~/.dropbox-dist/dropboxd

save and name it "dropbox". Now you can run from console in background or create a shortcut in your menu/desktop

share|improve this answer
    
This is incorrect as it would just run in the foreground. You would have to still do dropbox & to send it to the background. Additionally if the terminal connection is ended, then the Hangup signal will kill the process. –  sparticvs Aug 14 '13 at 0:36

run the command in this way:

($HOME/.dropbox-dist/dropboxd &)&

this will detach the process from tha actual terminal and put it in real background.

You will still have to start it back up manually after a reboot, though.

share|improve this answer

I added the following lines to the end of my .profile file. I prefer to have the computer boot at terminal. However, if I start X11 after this, the dropbox applet is not displayed on the system tray.

dropbox running
rv=$?
if [ $rv -eq 0 ]; then
    dropbox start;
fi
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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