Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Contact Us
Online Help
Domain Status
Man Pages

Virtual Servers

Topology Map

Server Agreement
Year 2038

USA Flag



Man Pages

Manual Reference Pages  -  REX (1)

.ds Aq ’


(R)?ex - (Remote)? Execution



Rex is a command line tool which executes commands on remote servers. Define tasks in Perl and execute them on remote servers or groups of servers.

Rex can be used to:
- Deploy web applications to servers sequentially or in parallel.
- Automate common tasks.
- Provision servers using Rex’s builtin tools.


    bash# rex -h                      # Show usage
    bash# rex -T                      # List tasks
    bash# rex uname                   # Run the uname task
    bash# rex -H server[01..10] uname # Run the uname task on all the specified hosts
    bash# rex -G production uname     # Run uname on hosts on the production hostgroup
    bash# rex deploy --gracefully     # Pass --gracefully to the deploy task


    rex [<options>] [-H <host>] [-G <group>] <task> [<task-options>]
    rex -T[m|y|v] [<string>]

    -b     Run batch
    -e     Run the given code fragment
    -E     Execute a task on the given environment
    -G|-g  Execute a task on the given server groups
    -H     Execute a task on the given hosts (space delimited)
    -z     Execute a task on hosts from this commands output
    -K     Public key file for the ssh connection
    -P     Private key file for the ssh connection
    -p     Password for the ssh connection
    -u     Username for the ssh connection
    -d     Show debug output
    -ddd   Show more debug output (includes profiling output)
    -m     Monochrome output: no colors
    -o     Output format
    -q     Quiet mode: no log output
    -qw    Quiet mode: only output warnings and errors
    -Q     Really quiet: output nothing
    -T     List tasks
    -Tm    List tasks in machine-readable format
    -Tv    List tasks verbosely
    -Ty    List tasks in YAML format
    -c     Turn cache ON
    -C     Turn cache OFF
    -f     Use this file instead of Rexfile
    -F     Force: disregard lock file
    -h     Display this help message
    -M     Load this module instead of Rexfile
    -O     Pass additional options, like CMDB path
    -s     Use sudo for every command
    -S     Password for sudo
    -t     Number of threads to use (aka parallelism param)
    -v     Display (R)?ex version


When you run rex it reads the file Rexfile in the current working directory. A Rexfile consists of 2 major parts: Configuration and Task Definitions.


Simple Authentication

    user "bruce";
    password "batman";

Key Authentication

    private_key "/path/to/your/private/key.file";
    public_key "/path/to/your/public/key.file";

Define Logging

    logging to_file => "rex.log";
    logging to_syslog => "local0";

Group your servers

Rex gives you the ability to define groups of servers. Groups can be defined the Rexfile:

    group "frontends" => "frontend01", "frontend02", "frontend03", "frontend04", "frontend[05..09]";

Groups can also be defined in a <B>server.iniB> file:


    Other Configuration

    timeout 10;    # ssh timeout
    parallelism 2; # execute tasks in parallel

    Defining tasks

A basic task looks like this:

    # task description
    desc "This task tells you how long since the server was rebooted";
    # task definition
    task "shortname", sub {
        say run "uptime";

You can also set a default server group:

    desc "This is a long description of a task";
    task "shortname", group => "frontends", sub {
        say run "uptime";

Search for    or go to Top of page |  Section 1 |  Main Index

perl v5.20.3 REX (1) 2016-03-07

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.