46

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 working and I need to run that daemon again.

How can I have the computer automatically start that daemon in the background?

2
  • 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).
    – WhyNotHugo
    Apr 3, 2012 at 16:58
  • Perhaps nohup? unix.stackexchange.com/questions/56495/…
    – njsg
    Feb 7, 2013 at 14:43

16 Answers 16

62

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
4
  • 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, 2013 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, 2013 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, 2013 at 17:30
  • 1
    @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, 2014 at 20:31
15

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.

14

Here is my solution. This is on Debian 8.

Install Dropbox as per standard instructions. So far, I've only got one user connected, I don't know if this will work with multiple users as dropbox seems to register the machine and not the linux user account. If you know how to get multiple user accounts on one server working let us know.

https://www.dropbox.com/en_GB/install?os=lnx

Then install the python control script instructions but put it in /usr/bin and not your home directory bin.

Create file /lib/systemd/system/[email protected]:

[Unit]
Description=Dropbox as a system service user %i

[Service]
Type=forking
ExecStart=/usr/bin/dropbox start
ExecStop=/usr/bin/dropbox stop
User=%i
Group=%i
# 'LANG' might be unnecessary, since systemd already sets the
# locale for all services according to "/etc/locale.conf".
# Run `systemctl show-environment` to make sure.
Environment=LANG=en_US.utf-8

[Install]
WantedBy=multi-user.target

Enable the service for user fred:

$ sudo systemctl enable [email protected]

Then start the service:

$ sudo systemctl start [email protected]
3
  • 1
    I like your answer, just a couple things I change. I'd add After=network.target under [Unit] and put the python file in /usr/local/bin per unix.stackexchange.com/questions/8656/… Mar 5, 2017 at 1:50
  • This answer ammended by Northstrider's comment should be part of the official documentation provided by Dropbox. Aug 12, 2022 at 15:27
  • What's the difference between dropbox and dropboxd as provided in the distribution?
    – NeilG
    Aug 20 at 10:56
5

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...

4

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.

3

Have a look here:

https://community.spiceworks.com/topic/131973-dropbox-headless-workstation?page=1#entry-6076539

A user mentioned:

Just thought I'd mention:

(a) the latest distributions seem to make this fairly straightfoward, just run dropbox start from the command line, BUT (b) watch out for logging in and out with X11 forwarded.

I've set up a lot of Bash aliases for connecting to various machines, and they all include the -X option to forward X11 packets. Because of this, Dropbox kept dying on my on logout, even running it under screen and with nohup. Apparently, having X11 forwarded was causing Dropbox to connect the dbus process on my local machine rather than on the remote machine; so, when I broke the connection, Dropbox was seeing dbus as having terminated and thus was terminating itself.

Just FYI, as this stumped me for a bit. The key was that I was having to press Ctrl-C even after logging out / running exit on the remote machine. Apparently, SSH was keeping the session open, even though I had exited Bash, because of the remaining open connection.

The solution is simple even if one (for some reason) wants to keep ssh-ing with the -X: before launching Dropbox you should "break" the forwarding for example doing:

$ unset DISPLAY

If this is done in a Bash script the forwarding is "broken" just inside the script but once this is executed the 'terminal' is still forwarding.

3

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.

2

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.

2

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.

1

It might not be useful for all Linux distros, but in CentOS 7, from Applications/System Tools/ menu, open 'Startup Applications'. Then click Add, and enter this command:

/home/username/.dropbox-dist/dropboxd

or

/home/.dropbox-dist/dropboxd

enter image description here

1
  • @roaima thanks for your judgment. Which other solution? I just posted the solution which worked for me.
    – Aryo Z
    Dec 8, 2016 at 5:35
0

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
1
  • Assuming you really do mean [ $rv -eq 0] (and not [ $rv -ne 0 ]) you could simplify all that with dropbox running && dropbox start Dec 8, 2016 at 12:07
0

This site seems to have complete information on how to install and configure dropbox on Linux, including downloading and installing the CLI, creating soft links outside of dropbox, and running dropbox as a daemon. The latter provides an init.d script that will enable dropboxd to be controlled with service and chkconfig.

http://www.dropboxwiki.com/tips-and-tricks/install-dropbox-centos-gui-required

0

download the script provided by dropbox https://www.dropbox.com/download?dl=packages/dropbox.py and run

python dropbox.py start

If you don't have python you will need pyhon to run this

0

1- install Dropbox (reference: https://www.dropbox.com/install-linux):

32 bits:

cd ~ && wget -O - "https://www.dropbox.com/download?plat=lnx.x86" | tar xzf -

64-bit:

cd ~ && wget -O - "https://www.dropbox.com/download?plat=lnx.x86_64" | tar xzf -

2- Execute (you have to execute at least one time, to log in Dropbox)

~/.dropbox-dist/dropboxd

3- Download this script:

cd ~/Downloads
wget https://www.dropbox.com/download?dl=packages/dropbox.py
mv download?dl=packages%2Fdropbox.py dropbox.py
mv dropbox.py ~/bin/dropbox.py
chmod 755 ~/bin/dropbox.py

You can use this command to get help about the script:

~/bin/dropbox.py help

4- Set autostart

~/bin/dropbox.py autostart y
~/bin/dropbox.py start
~/bin/dropbox.py status

As mentioned by @Zac there are a good explanation about each step here: http://pixeldust.wikidot.com/linode-setup%3adropbox

-1

The solution is as other python programs :

shell$ nohup ~/.dropbox-dist/dropboxd & 
-2

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

1
  • 2
    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, 2013 at 0:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .