Skip to main content

Shell-based job runner with logging

Project description

Job runner with logging

Build Status PyPI Release

Installation

Install system-wide:

$ pip install shell-jobrunner

Install just for the current user:

$ pip install --user shell-jobrunner

Uninstallation

$ pip uninstall jobrunner

Examples

  • Run sleep 5 in the background

    $ job sleep 5
  • Run ls when the last job finishes and it passed (exit code 0)

    $ job -B. ls
  • Run ls when last job finishes (pass / fail)

    $ job -b. ls
  • Monitor job execution

    $ job -W
    Sat Aug 10, 2019 20:48:23  No jobs running, load: 0/0/0
  • Retry a job

    $ job --retry ls

Query Examples

NOTE . is available as an alias to the most recently executed job (as in the Examples above).

  • View recently executed job log file

    $ job ls
    $ view `job`   # Opens the output from ls using "view"
  • View two most recently executed

    $ job echo 1
    $ job echo 2
    $ view `job -n0 -n1`
  • Query by job name

    $ job echo foo
    $ job echo bar
    $ view `job -g foo`
  • Show job info by name

    $ job ls
    $ job -s ls

Configuration

The default configuration file location is ~/.config/jobrc, but can be
overridden using the –rc-file option.

Sample rcfile:

[mail]
program = mail
# For notifications over chat applications (like Google Chat), use chatmail as
# your mail program instead. "chatmail" must be specified rather than a differently
# named link to the script, else some options provided to job (such as --rc-file)
# will not be passed through to it.
# program = chatmail
domain = example.com
[ui]
watch reminder = full|summary  # default=summary
[chatmail]
at all = all|none|no id # default=none
reuse threads = true|false # default true
[chatmail.google-chat-userhooks]
user1 = https://chat.googleapis.com/v1/spaces/...
[chatmail.google-chat-userids]
# Retrieve this using your browser inspector on an existing mention of this user.
# It should show up as "user/some_long_integer" somewhere in the span's metadata.
user1 = <long integer>

System Notifications (Systemd user service example)

If you want to enable notifications when jobs finish, one way to do this is to use the –notifier argument.

~/.config/systemd/user/job-notify.service:

[Unit]
Description=Jobrunner Notifier

[Service]
Type=simple
ExecStart=env job --notifier jsonNotify.py
RestartSec=30
Restart=always

[Install]
WantedBy=default.target

~/.local/bin/jsonNotify.py:

#!/usr/bin/env python3

from json import load
import subprocess
from sys import stdin

cmd = ["notify-send"]
data = load(stdin)
rc = data.get("rc", 0)
if rc != 0:
    cmd += ["--urgency=critical"]
cmd += [data["subject"], data["body"]]
subprocess.run(cmd)

Hacking

Primary workflow

It’s highly recommend to work inside a virtualenv using pipenv.

Create new virtualenv and install an editable version of jobrunner:

pipenv --three install --dev
pipenv run pip install -e .

Autoformat the code and check linters:

pipenv run ./format.sh

Run tests:

pipenv run pytest

Run CI checks locally

This allows you to run something similar to the azure pipelines locally using docker.
It will use PIP_INDEX_URL and / or ~/.config/pip/pip.conf to configure a pypi mirror.
This will also update Pipfile*.lock.
./test-docker.py [--versions 2.7 3.7 3.8] [--upgrade] [--ignore-unclean]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shell_jobrunner-3.0.0a16.tar.gz (95.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

shell_jobrunner-3.0.0a16-py3-none-any.whl (115.1 kB view details)

Uploaded Python 3

File details

Details for the file shell_jobrunner-3.0.0a16.tar.gz.

File metadata

  • Download URL: shell_jobrunner-3.0.0a16.tar.gz
  • Upload date:
  • Size: 95.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for shell_jobrunner-3.0.0a16.tar.gz
Algorithm Hash digest
SHA256 b6f4160c97ff6b5d1b26507826c691b83fb4174db76e6a7b048b4862201ecd23
MD5 7f1f3d8377f4b756b6fdf82329830100
BLAKE2b-256 4d410744ea84d5d8caa0fa14bbe08718e5f51edfc9558c94065184f1520e37b9

See more details on using hashes here.

Provenance

The following attestation bundles were made for shell_jobrunner-3.0.0a16.tar.gz:

Publisher: python-publish.yml on wwade/jobrunner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file shell_jobrunner-3.0.0a16-py3-none-any.whl.

File metadata

File hashes

Hashes for shell_jobrunner-3.0.0a16-py3-none-any.whl
Algorithm Hash digest
SHA256 f15c4332171f1c55cfe388aadb8816efb49b1c62f4d9e7dd4d4811b752407e30
MD5 7a1f67f61a369a05b3c5803c680b573e
BLAKE2b-256 f0a2771fc121b3d6f728fe98bb71ec76d3d4a921a56c09a3b3944d131af0fff1

See more details on using hashes here.

Provenance

The following attestation bundles were made for shell_jobrunner-3.0.0a16-py3-none-any.whl:

Publisher: python-publish.yml on wwade/jobrunner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page