Skip navigation

Automator script sometimes fails when run as Application

1589 Views 17 Replies Latest reply: Feb 24, 2013 12:05 AM by BordeauxQuill RSS
1 2 Previous Next
BordeauxQuill Calculating status...
Currently Being Moderated
Feb 10, 2013 2:00 PM

I have created an Automator script that performs the followig five actions:

 

1) Run Shell Script

 

Command is rsync -av --exclude-from="/Volumes/X/rsync Library/rsync Exclusions/username-exc.txt" --log-file="/Volumes/X/rsync Library/rsync Logs/rsync-username.txt" /Users/username/ /Volumes/X/rsync-username

shell: /bin/hash

Pass input; as arguments

Ignore this action's input: checked

 

I found these parameters by looking at others' attempts to automate rsync.  The rsync Terminal command works perfectly - I have been using it for a while.

 

2) New Text File (to create a run-specific log, separate from the master created by rsync)

 

3) Add Date or Time (to add date to log filename)

 

4) Add Date or Time (to add date to log filename)

 

5) Copy Finder Items (to copy the log to the Desktop so that I might see when the job is complete)

 

This workflow functions properly when I run it from within Automator.

 

The problem is that when I have saved the script as an Automator Application, it sometimes runs fine and on other occasions - seemingly randomly, maybe one minute later - I get an error: 'The action "Run Shell Script" encountered an error. // Check the action's properties and try running the workflow again.'  Disks are still connected, etc.

 

I thought maybe I could compromise and use Automator Runner (1.1.2), but when I Open With that nothing seems to happen at all.

 

Any thoughts would be appreciated.  Thank you.

MacBook Air, OS X Mountain Lion (10.8.2)
  • twtwtw Level 5 Level 5 (4,580 points)

    rsync error 24 is "Partial transfer due to vanished source files".  did your source files move before rsync was finsished?

  • twtwtw Level 5 Level 5 (4,580 points)

    Easiest might be to write the error stream to a file.  Automator Run Shell Script will always stop when it gets an error message back from a script, but if you can catch the error before it returns it may continue processing.

  • twtwtw Level 5 Level 5 (4,580 points)

    Well, rsync is not exactly a typical utility; it has it's own style, and it runs multiple sub processes, so maybe normal redirection doesn't work as expected with it.  Unfortunately I'm only middling good with unix.  you'll probably need to wait until one of the unix pros weighs in.

  • twtwtw Level 5 Level 5 (4,580 points)

    If I were you I'd just exclude the preferences folder, or maybe make a static copy to a local directory and archive that. Preference files are modified frequently (I see changes in that folder as fast as the Finder updates its views, so at least every ten seconds), and the user defaults system seems to use a delete-then-rewrite strategy for plist updates, rather than updating existing files.  That means you'll always have files disappearing and reappearing in that folder, and rsync will never be happy.

  • Hiroto Level 5 Level 5 (4,810 points)

    Hello

     

    Have you tried "exit 0" as the last command in shell script? I ask this because you only wrote you tried adding "exit" after rsync. When you use exit without number, the exit status is that of the last command executed, which is 24 from rsync in this case.

     

    E.g., try something like this if you have not:

     

    #!/bin/bash
    rsync OPTIONS SRC DEST > /path/to/errlog.txt 2>&1
    exit 0
    

     

    Regards,

    H

  • Hiroto Level 5 Level 5 (4,810 points)

    Hello

     

    My pleasure. Glad to hear it helped.

     

    It is quite easy to implement a) exit 0 only if error = 24. Like this:

     

    rsync -a --stats --exclude-from="/path/exclude.txt" --log-file="/path/log.txt" "/path/src/" "/path/dest"
    ret=$?
    if [[ $ret -eq 24 ]]; then exit 0; fi
    exit $ret
    

     

    As for b), I have no idea because I don't know 10.8.

     

    Kind regards,

    H

     

    Message was edited by: Hiroto (fixed the code)

1 2 Previous Next

Actions

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.