backrun
Run other (whitelisted) programs/scripts in background (and maybe as another userid) and save stdout/stderr in log. You may need this when you want to start other long-running scripts (like sync databases) from web-UI.
Install
# for this user only
pipx install backrun
# for all users
sudo PIPX_HOME=/opt/pipx PIPX_BIN_DIR=/usr/local/bin pipx install backrun
# old fashioned way
pip3 install backrun
Run background tasks
Prepare config file backrun.toml, and run backrun.
When you need to start some background process, do this:
echo script1 > /var/backrun/task/123
This will create task file to run script1 with id 123.
Almost immediately backrun will start to execute script and write stdout/stderr to /var/backrun/tasklog/123.log.
When script will finish, backrun will delete task file.
Details
Script will be executed with uid of backrun script.
Backrun reads only first like of taskfile, so you can put everything (any text, YAML, JSON) starting with 2nd line and script can read it.
script will get environment of backrun. backrun will set two new environment variables for script:
TASKID - if of task (e.g. "123"), TASKFILE - path to task file. If user is set, HOME variable is redefined too.
Example files
config file
Config file name is either passed as first argument to backrun or first existing file in: ./backrun.toml, ~/backrun.toml, /etc/backrun.toml.
taskdir = "/var/backrun/task"
logdir = "/var/backrun/tasklog"
logfile = '/var/backrun/backrun.log'
[scripts]
[scripts.script1]
path="/usr/local/bin/script1.sh"
[scripts.script2]
path="/usr/local/bin/script1.sh"
user="myuser"
script file (script1.sh)
#!/bin/bash
log(){
echo `date "+%Y-%m-%d %H:%M:%S"` $*
}
log started as user `whoami`
sleep 10
>&2 log "error"
log finished
systemd service file
change User and ExecStart
[Unit]
Description=backrun: run whitelisted scripts in background
[Service]
ExecStart=/usr/local/bin/backrun
# User=xenon
[Install]
WantedBy=multi-user.target
Metadata
Release files for backrun 0.0.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| backrun-0.0.9.tar.gz | 5.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| backrun-0.0.9-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.7 kB
Release files / backrun-0.0.9.tar.gz
| Download URL | backrun-0.0.9.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fb1633085b3a317effcce38dfb1558b1b242e6158d1fe26c62f1d1be0296e134
|
|
BLAKE2b-256 checksum How to use checksums |
43065b45cc0c32f7423384c9077b8fcd304c910aa8afd25297b46ac8a1517163
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-httpx/0.25.2
|
Release files / backrun-0.0.9-py3-none-any.whl
| Download URL | backrun-0.0.9-py3-none-any.whl |
|---|---|
| Size | 4.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5f22a5a5716bd6a17ed1e5e76aff64d47435d6ceecefda36dfe2945f19809205
|
|
BLAKE2b-256 checksum How to use checksums |
aa6cdfb3e0e4f1a9a98f0b34b7863cc7bd6c62cb5c9a635d6e9be89fd54f1b1b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-httpx/0.25.2
|
Security for backrun 0.0.9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.