Results 1 to 5 of 5

Thread: Process status check fails in CRON

  1. #1
    Join Date
    Mar 2014
    Beans
    69

    Process status check fails in CRON

    Ok, so I have a job that runs and depends on files in Dropbox. Essentially I have a checkpoint to make sure that dropbox isn't downloading new files before running the job.

    Here's the code:

    Code:
    CUR_STATUS=$(dropbox status)
    
    if [ "$CUR_STATUS" = "Up to date" ]; then
            echo "$CUR_STATUS" > $DIR/test.log
    else
            echo "dropbox isn't updated" > $DIR/test.log
            echo "status is : +$(/usr/bin/dropbox status)+" >> $DIR/test.log
            echo "running is : +$(/usr/bin/dropbox running)+" >> $DIR/test.log
            echo "whoami: +$(whoami)+" >> $DIR/test.log
            echo "debug early exit" >> $DIR/test.log
            exit_flag=1
    fi
    There's a few extra lines for debugging purposes but essentially this WORKS when running the script manually in terminal. AND it also ran under cron in a Ubuntu machine until we decided to move over to CentOS where it has now broken.

    I think the problem lies in CRON but cannot work out why or how?

    Andrew

  2. #2
    Join Date
    Mar 2014
    Beans
    69

    Re: Process status check fails in CRON

    To clarify:

    Run manually - status is "Up to date"
    Under CRONTAB - status is "Dropbox isn't running!"

    I have the package nautilus-dropbox installed (Version : 2015.02.12
    Release : 1.fc10)

    And dropbox looks to be v3.4.6 - ~/.dropbox-dist/dropbox-lnx.x86_64-3.4.6/

  3. #3
    Join Date
    May 2010
    Location
    uk
    Beans
    9,249
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: Process status check fails in CRON

    Hi

    Code:
    CUR_STATUS=$(dropbox status)
    Use the full path to dropbox and whoami.


    Cron has a sanitised environment for security reasons and will not contain many of your environmental variables including your PATH variable so use full paths otherwise cron will not know where to look for executables.

    EDIT:

    I think that it may be missing a number of paths including the path to your home directory for ~/.dropbox-dist/dropbox-lnx.x86_64-3.4.6/

    My point is, look at your cron's PATH and other environmental variables that dropbox may need when run from cron.

    Kind regards
    Last edited by matt_symes; June 5th, 2015 at 12:43 PM.
    If you believe everything you read, you better not read. ~ Japanese Proverb

    If you don't read the newspaper, you're uninformed. If you read the newspaper, you're mis-informed. - Mark Twain

    Thinking about becoming an Ubuntu Member?

  4. #4
    Join Date
    Mar 2014
    Beans
    69

    Re: Process status check fails in CRON

    Thanks for your reply.

    This code is extracted from the script, so the PATH= is there but not shown in this thread.
    I already had /usr/bin and /home/user/Dropbox.
    Adding /home/user/.dropbox-dist did not make a difference.

    dropbox status returns "Dropbox isn't running!"
    dropbox running returns 0

    Still haven't worked it out. All I know is it was working fine in Ubuntu before. So figured maybe there are some extra "features" of CentOS that prevent cron from working as expected.

  5. #5
    Join Date
    Mar 2014
    Beans
    69

    Re: Process status check fails in CRON

    I think I found the solution:

    HOME=/ [change this to /home/<my-user>]

    Add:
    USER=<my-user>

    to /etc/crontab

    Now dropbox status says "Up to date" - yay!
    dropbox running still returns 0 but this isn't so important as we can just equate on the string.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •