Search code examples
linuxbashterminaldropbox

check if command is running in bashrc


Here is my question. Since there is a problem for my dropbox folder to do automatics sync. I have to add " ~/.dropbox-dist/dropboxd &" in my .bashrc. So whenever I open my terminal, it will automatically start synchronizing. The problem arise when I want to have another tab in my terminal. I am receiving following warning that "Another instance of Dropbox (8664) is running! ". Although it does not affect my dropbox, it is quite annoying. I searched but unfortunately I could not find the solution on the web. So any help will be appreciated in advance.

Thanks


Solution

  • add it to yout .bashrc

    ps cax | grep dropbox > /dev/null
    if [ $? -eq 0 ]; then
      echo "Process is running."
    else
      ~/.dropbox-dist/dropboxd &
      echo "Process is not running."
    fi