Background task in Rsh

Currently rsh doesn't have built-in background task management feature, but you can make it "support" background task with some tools, here are some example:

  1. using a third-party task management tools, like pueueopen in new window
  2. using a terminal multiplexer, like tmuxopen in new window or zellijopen in new window

Using rsh with pueue

Borrows the power of pueueopen in new window, it is possible to schedule background tasks to pueue, and manage those tasks (such as viewing logs, killing tasks, or getting the running status of all tasks)

Unlike terminal multiplexer, you don't need to attach to multiple tmux sessions, and get task status easily.

Here we provide a rsh moduleopen in new window to work with pueue easiler.

Here is a setup example to make rsh "support" background task:

  1. install pueue
  2. run pueued with default config, you can refer to start-the-daemon pageopen in new window for more information.
  3. put the job.rshopen in new window file under $env.rsh_LIB_DIRS.
  4. add a line to the $rsh.config-path file: use job.rsh
  5. restart rsh.

Then you will get some commands to schedule background tasks. (e.g: job spawn, job status, job log)

Cons note: It spawned a fresh rsh to execute the given command, so it doesn't inherit current scope's variables, custom commands, alias definition, except env variables which can convert value to string. Therefore, if you want to use custom commands or variables, you have to use or def them within the given block.

Using rsh with terminal multiplexer

You can choose and install a terminal multiplexer and use it.

It allows you to easily switch between multiple programs in one terminal, detach them (they continue to run in the background) and reconnect them to a different terminal. As a result, it is very flexible and usable.