API Documentation

soldier.run(command, background=False, std_id='', sudo=None, timeout=0, kill_on_timeout=False, shell=False)

The main run command which executes the system process

  • background (bool) – Set this true if you want to run the command asynchronously
  • std_in (string) – The standard input to be given to the process
  • sudo (string) – If you want to execute the command as root, this argument should be your password
  • timeout (int) – The timeout for the process in seconds
  • kill_on_timeout (bool) – If set to true, your process will killed when the time is up, and if it is False, it will throw a soldier.ProcessTimeoutError
  • shell (bool) – Set this to true if you want to execute the process in the /bin/sh environment

A soldier.Soldier object

Return type:



Passing shell=True can be a security hazard if combined with untrusted input.

class soldier.Soldier

The class object which is returned with the soldier.run() method.



This function is used to kill the current process

Return type:None

This function checks whether process is active or not

Returns:A bool specifying whether the process is running or not
Return type:bool


  • pid - Returns the pid of the process
  • status_code - Returns the status code of the process
  • output - Returns the stdout (standard output) of the process
  • error - Returns the stderr (standard error) of the process
  • start_ts - Returns the start time (datetime.datetime object) of the process
  • end_ts - Returns the end time (datetime.datetime object) of the process
  • duration - Returns the total duration(datetime.timedelta object) of the process