Want to highlight a helpful answer? Upvote!

Did someone help you, or did an answer or User Tip resolve your issue? Upvote by selecting the upvote arrow. Your feedback helps others! Learn more about when to upvote >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Automator workflow "run shell script" keeps running. How to stop?

Because i want two instances of dropbox running simultaneously on my Mac, I set up a small automator workflow application. The workflow consist of a simple shell script:

User uploaded file


Or in text:


bash

HOME=$HOME/Dropbox-quivertree /Applications/Dropbox.app/Contents/MacOS/Dropbox &


The problem is that once the application runs, or i execute the script from within automator, it just keeps running (i get the little cog in my menubar). Anybody have an idea how to automatically stop after it has launched dropbox?


Thanks!


Kim

MacBook Air (13-inch Mid 2013), OS X Mavericks (10.9.4)

Posted on Aug 1, 2014 2:21 AM

Reply
Question marked as Best reply

Posted on Dec 1, 2014 3:11 AM

I solved this by running Dropbox like so, in Automator:


HOME="$HOME/Costum Dropbox Folder" nohup /Applications/Dropbox.app/Contents/MacOS/Dropbox > /dev/null 2>&1 &


The trick is to use nohup to "disown" the process from the Automater process, then background it. I also redirect standard output and standard error to /dev/null, just in case.


This worked for me.

12 replies
Question marked as Best reply

Dec 1, 2014 3:11 AM in response to Kim van der Leeuw

I solved this by running Dropbox like so, in Automator:


HOME="$HOME/Costum Dropbox Folder" nohup /Applications/Dropbox.app/Contents/MacOS/Dropbox > /dev/null 2>&1 &


The trick is to use nohup to "disown" the process from the Automater process, then background it. I also redirect standard output and standard error to /dev/null, just in case.


This worked for me.

Aug 1, 2014 9:26 AM in response to Kim van der Leeuw

Then it really doesn't matter that it is in the background. It is because you are running a shell that launches Dropbox. If you quit that shell, it will Quit dropbox. If the automator workflow quits, so does the shell you invoked, and the programs you invoked from within it.


Can you use

open -n Dropbox.app


https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/ man1/open.1.html

Oct 9, 2014 9:28 PM in response to Kim van der Leeuw

You can do it by:

1. Run:

sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.atrun.plist

sudo launchctl start com.apple.atrun

in Terminal to startup the AT.

2. Write

echo "<your command>" | /usr/bin/at now

for yor Automator shell script. Instead <your command> to your command.

e.g.

echo "/usr/bin/ssh -NL 0.0.0.0:10800:localhost:1080 Tunnel@127.0.0.1" | /usr/bin/at now

echo "/usr/bin/open xxx.app" | /usr/bin/at now

And in this way, you can keep shell command running at background, and quit Automator workflow normally.

PS: You should wait few seconds for AT run the command at background event "now" we specified.

Dec 8, 2014 7:03 PM in response to Kim van der Leeuw

I do not have dropbox on my computer, so I tested using the Calculator application. The solution proposed by Mattis S.F. does work, but his explanation does not hold true in my case. Initially, I successfully tried


HOME=$HOME/Dropbox-quivertree nohup /Applications/Calculator.app/Contents/MacOS/Calculator >/dev/null 2>&1 &


If I remove the “nohup”, the result does not change. Removal of the “/dev/null 2>&1”, however, results in the same problem originally described by Kim van der Leeuw. My guess is the background process has stdout and stderr redirected by default back to the automator. When redirected to /dev/null, the automator no longer waits for the background process to complete. To summarize, change


HOME=$HOME/Dropbox-quivertree /Applications/Dropbox.app/Contents/MacOS/Dropbox &


to


HOME=$HOME/Dropbox-quivertree /Applications/Dropbox.app/Contents/MacOS/Dropbox >/dev/null 2>&1 &

Dec 11, 2014 11:59 AM in response to davidanderson61

I found a reference which answers the question:


Technical Note TN2065

do shell script in AppleScript

at

https://developer.apple.com/library/mac/technotes/tn2065/_index.html


Search for the following text:

I want to start a background server process; how do I make do shell script not wait until the command completes?

The answer is the same as I gave in my previous post.

Automator workflow "run shell script" keeps running. How to stop?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.