Help with understanding capistrano shell command

run "cd #{current_path} && RAILS_ENV=#{stage} && bundle exec puma -b '#{puma_sock}' -e #{stage} -t2:4 --control '#{puma_control}' -S #{puma_state} >> #{puma_log} 2>&1 &", :pty => false

I understand eveything except the part starting from “>> #{puma_log} 2>&1 &” in the above command.

I have seen ‘>>’ in many places where it basically sends the output of the command on left side to the file on the right. but I am not sure what this ‘2>&1 &’ has to do with?

also what is the ‘:pty => false’ doing here?

if there is any good resource that helps to understand the basics of the above, pls point me to that.

Thanks

@shankard… there are actually several parts to that chunk.

  1. The trailing ‘&’ starts the quoted script running in the background
  2. the ‘2>&1’ combines stdout (the ‘1’) and stderr (the ‘2’) into a
    single output stream so that they both get merged into the output
    file
  3. the ‘#{puma_log}’ part names the output file that will contain
    the merged output
  4. the ‘>>’ is a shell redirection of the output to
    the named file. ‘>>’ appends to an existing file, in contrast to ‘>’
    which overwrites any pre-existing file.

Mark Sobell has written an awesome book on the topic: "A Practical Guide to Linux Commands, Editors, and Shell Programming. And there’s also a nice online Advanced BASH Scripting Guide that will help.