Scheduled Command Wrapper

Current version: 0.0.0 (Not released)

scw extends scheduled commands to add concurrency locking, prerequisites, dependency checks, conflict avoidance, randomised startup delays, flexible logging, and monitoring metrics.

There are no complex dependencies - all you need to run scw is a scheduler such as cron.

Purpose

Many scheduled commands either dump their output into an email, or write logs which maybe have a start and end timestamp, but nothing in between. If the operator doesn’t get the email or check the logs, they won’t know about errors.

For example an old script might run 3 backups and produce a log like this:

Starting at Sat  9 Nov 10:42:22 GMT 2024
Backup job 1 OK
tar: /root: Cannot open: Permission denied
Backup job 2 failed!
Backup job 3 OK
Finished at Sat  9 Nov 13:42:43 GMT 2024

Searching the log for “failed” won’t say which day contained the failure, if the log spans several days - and there’s no way to tell specifically when backup job 2 failed, making fault analysis difficult.

Running the same script under scw* produces logs like this:

2024-11-09T10:42:22 [s] (begin)
2024-11-09T10:42:22 [-] Starting at Sat  9 Nov 10:42:22 GMT 2024
2024-11-09T11:20:01 [-] Backup job 1 OK
2024-11-09T11:30:47 [E] tar: /root: Cannot open: Permission denied
2024-11-09T11:50:55 [-] Backup job 2 failed!
2024-11-09T13:42:42 [-] Backup job 3 OK
2024-11-09T13:42:43 [-] Finished at Sat  9 Nov 13:42:43 GMT 2024
2024-11-09T13:42:43 [s] (end) exit status 1, elapsed time 10821s

The output is timestamped, the exit status of the script is recorded, and an error marker file is created for monitoring systems to detect. This is all done without having to change the original script.

Features

Each distinct scheduled command is referred to as an “item” and can have its own configuration for each of these features:

In its simplest form, scw can be invoked from existing scheduler entries like this:

# Original entry
0 * * * * /some/command --option ARGUMENT
 
# Replacement
0 * * * * scw run mycommand -- /some/command --option ARGUMENT

To make use of the full range of features, scheduled command definitions can instead be placed into the scw item definition directory, and “scw update” can then generate the appropriate crontab.


This software is distributed under the terms of the GNU General Public License version 3 or later.

This package has not yet been released, as it is not yet in a usable state. See the Git repository for the current source code.

Comments, bug reports, and patches can be sent using the Issue tracker, or through the Contact Form.

News

This package has no releases yet.