I have a couple of encrypted drives that I mount manually with a script after start. One of those drives hosts my dropbox folder.
I need to check if dropbox is running when mounting the drive so that I can stop dropbox and then start it again so it syncs correctly.
This is what I have so far, but I can't get it to stop dropbox if it's already running.
#!/bash/rc
if ~/dropbox.py running && [ $? -eq 1 ]; then
~/dropbox.py stop
else
~/dropbox.py start
fi
To restart Dropbox, find the application on your computer and double-click it. You may need to log back in, using your existing Dropbox credentials (email address and password).
The Dropbox desktop app is available on supported Linux operating systems. If you use Dropbox on a Linux machine, we recommend that you download and install the appropriate Linux package of the Dropbox desktop app.
Try
killall dropbox
This is going to stop it for sure! By default SIGTERM is sent, which is a right way to stop a process. If your system supports multiple simultaneous user logins, then this command is going to terminate dropbox for all users, or at least it will attempt to do so. So more elegant way is to use
killall -u myusername dropbox
and if you're currently logged in by that user:
killall -u "$(whoami)" dropbox
Or maybe even
killall -u "$USER" dropbox
Update: well, it seems like people like this answer. However, there is one important thing to know. Just sending a signal to a process does not really mean that it will terminate immediately (or that killall is going to wait for it to terminate). So it is possible that dropbox will attempt to terminate safely (which could take some time to finish) when you assume that it is already gone. Just a thing to consider.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With