Menu

Tree [09f980] master /
 History

HTTPS access


File Date Author Commit
 tests 2024-05-01 vincent.delft vincent.delft [e29d8d] add rootID check
 INSTALL 2018-07-05 vincent.delft vincent.delft [64ecf5] Add a regression testing script. Contains 20 te...
 Makefile 2024-05-01 vincent.delft vincent.delft [699858] improve Makefile
 README.md 2024-12-15 vincent.delft vincent.delft [8c8951] document how to use optinal "context" parameter
 vdcron 2024-12-15 vincent.delft vincent.delft [5a71db] increment version
 vdcron.8 2024-12-15 vincent.delft vincent.delft [8c8951] document how to use optinal "context" parameter
 vdcron.conf.8 2024-11-06 vincent.delft vincent.delft [e94c92] adapt man pages to the remove of HHMM
 vdcron_root.conf 2024-12-28 vincent.delft vincent.delft [09f980] adapt sample vdcron.conf with new command param...

Read Me

vdcron

vdcron is a scheduling utility designed to replace cron for systems that do not run continuously, such as laptops. Unlike traditional cron, vdcron does not assume a machine is always on and instead runs scheduled tasks when triggered by an external event, such as waking up from sleep.

Features

  • Flexible Scheduling: Schedule tasks based on specific dates, intervals, weekdays, or months, similar to cron.
  • Trigger-Based Execution: vdcron isnīt a background daemon. Instead, itīs designed to be triggered by external events, such as system resume or user login.
  • Resilient Task Execution: Ensures tasks run when the schedule is met, even if delayed by system downtime. Failed tasks remain in the schedule for retry.
  • Dynamic Rescheduling: Tasks can be configured to re-run at intervals, making it ideal for periodic jobs.

How It Works

Since vdcron does not run continuously, it must be triggered by other means. For example:
- Resume from Sleep: On OpenBSD, trigger vdcron via the apmd resume script:

obsd:~ # cat /etc/apm/resume
#!/bin/sh
/usr/local/bin/vdcron "/etc/apm/resume"

Ensure apmd is enabled:

rcctl enable apmd
rcctl start apmd
  • Other Triggers: vdcron can also be run at startup, on user login, or even periodically with cron using @reboot.

Command-Line Options

  • -h: Display help information
  • -d: Debug mode for detailed logs
  • -s value: Set an initial sleep time (default: 10 seconds)
  • -f file: Specify an alternative config file (default: /etc/vdcron.conf for root or ~/.vdcron/vdcron.conf for other users)

Configuration File (vdcron.conf)

vdcron uses a configuration file, /etc/vdcron.conf for root or ~/.vdcron/vdcron.conf for regular users. Each line represents a task with a schedule and command. The format options include:

  • Date-Based: Run at a specific date or time, with optional repetition. Example:

    +20240101 echo "Happy New Year!"

  • Weekday and Month-Based: Run on specific weekdays or months, with optional intervals. Example:

    Monday/7 echo "Weekly Reminder"
    April/1 sh /etc/monthly_task

  • Always: Run every time vdcron is triggered:

    Always echo "System is active"

  • Rescheduling Failed Tasks: Tasks with a + prefix retry on failure, ensuring network or dependency issues do not prevent completion.

Example Configuration

+20240101 echo "Happy New Year!"
Sunday sh /etc/weekly_maintenance
Always /usr/local/bin/monitor_script
+20240101/1 sh /etc/daily_task

Logging

Output and errors are logged to /var/log/vdcron.log for root or ~/.vdcron/vdcron.log for other users. Logging can be suppressed with the -q option in the configuration file.

Author

Developed by Vincent Delft. Contact: vincent.delft@gmail.com

Compatibility

Tested on OpenBSD 6.3+ and on debian.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.