https://github.com/abiosoft/bgrun
Run processes in background
https://github.com/abiosoft/bgrun
process runner
Last synced: 11 months ago
JSON representation
Run processes in background
- Host: GitHub
- URL: https://github.com/abiosoft/bgrun
- Owner: abiosoft
- License: gpl-3.0
- Created: 2018-10-12T19:14:01.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-10-14T10:46:37.000Z (over 7 years ago)
- Last Synced: 2025-03-24T21:13:38.686Z (about 1 year ago)
- Topics: process, runner
- Language: Python
- Size: 21.5 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# bgrun
A simple tool to start a process in background and get the pid.
## Usage
```txt
$ bgrun -l ping.log ping 1.1.1.1
1234
$ tail -f ping.log
64 bytes from 1.1.1.1: icmp_seq=1 ttl=57 time=11.1 ms
64 bytes from 1.1.1.1: icmp_seq=2 ttl=57 time=12.4 ms
```
The process pid and log file can be used to monitor and terminate the process.
### List running commands
```txt
bgrun -r
[{"pid": 1234, "command": "ping 1.1.1.1", "log_file": "ping.log"}]
```
### Help
For full usage
```txt
$ bgrun -h
usage: bgrun [-h] [-l LOG_FILE] [-r] [-d] [-i] [-f] [command] ...
optional arguments:
-h, --help show this help message and exit
client:
-l LOG_FILE, --log-file LOG_FILE
file to direct command output to, otherwise output is
discarded.
command command to run.
args arguments to pass to command.
-r, --running list running commands, the output is json format.
daemon:
-d, --daemon start daemon.
-i, --ignore ignore running commands when daemon exits. By default,
bgrun terminates all running commands on exit.
-f, --force forcefully start even if the socket file exists. This
can be as a result of another bgrun daemon running, or
a previously running daemon did not terminate
gracefully.
```
## Install
* copy `bgrun` && `bgrun.py` to a directory in `$PATH`
* start daemon with `bgrun --daemon`
There is an helper install script that works for systemd based Linux.
```sh
git clone https://github.com/abiosoft/bgrun
cd bgrun && ./install.sh
```