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?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
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
Method 2
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.
Method 3
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 <a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a1c5d3ced1c3ced9e1c7d3c4c58fd2c4d3d7c8c2c4">[email protected]</a>
Then start the service:
$ sudo systemctl start <a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c2a6b0adb2a0adba82a4b0a7a6ecb1a7b0b4aba1a7">[email protected]</a>
Method 4
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…
Method 5
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.
Method 6
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 rundropbox 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 withnohup
. 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 / runningexit
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.
Method 7
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.
Method 8
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.
Method 9
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
.
Method 10
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
Method 11
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
Method 12
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
Method 13
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
Method 14
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
Method 15
The solution is as other python programs :
shell$ nohup ~/.dropbox-dist/dropboxd &
Method 16
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
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0