Automator gets stuck at shell script

automatorcommand linersyncscriptterminal

I am building an automator script to do automatic backups to a network drive via rsync. The shell script works perfectly fine in terminal and completes and everything, but when i run it from automator, it just hangs at that steps and never proceeds, e.g. the process keeps running in the background and the automator workflow never goes to the next step.

Screenshot from Automator (in danish)

I found others with similar problems on other forums, but no answer to how to fix it. Should i add some kind of exit command to the shell script?

Best Answer

I found this link helpful to solve a similar problem I was having:

https://discussions.apple.com/thread/1867978

I tried adding exit 0 to the end of my Automator shell script and it didn't seem to make a difference one way or the other.

After I read the above link I added this to the command in my Automator shell script:

>/dev/null 2>&1 &

It worked great. My Automator shell script now terminates normally.

In the above question, I believe the rsync command could be changed to:

rsync -aovE --delete /Volumes/STORAGE/Batting/Volumes/home/Backup >/dev/null 2>&1 &

If you wanted to log the output from your command, as I did, to a file /var/log/rsync.log then you could modify it to this:

rsync -aovE --delete /Volumes/STORAGE/Batting/Volumes/home/Backup >/var/log/rsync.log >/dev/null 2>&1 &