Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run a command on remote hosts through capistrano from the command line

Is there way to run a command in capistrano without adding it to a Capfile?

example:

cap --eval "run 'du -sh'" --role web
like image 613
Kostas Avatar asked Oct 11 '11 09:10

Kostas


2 Answers

You can use this to run a command on the servers.

cap ROLES=web invoke COMMAND='du -sh'

If you don't even have a cap recipe, you can specify the servers on the command-line:

cap -s user=myusername HOSTS=server1.com,server2.com invoke COMMAND='du -sh'

To see more command-line options, run cap -H and cap -e invoke.

like image 180
Kelvin Avatar answered Nov 16 '22 13:11

Kelvin


You can use the (experimental) Capistrano shell.

$ cap shell
like image 28
Simone Carletti Avatar answered Nov 16 '22 12:11

Simone Carletti