PowerRules¶
PowerRules is a rule-based command automation tool: when the conditions of a rule match, its commands run.
Originally built to shut down a computer at the right moment, it now runs any shell command.
How it works¶
- A policy is a YAML file with a list of rules.
- Each rule has conditions (processes, datetime, etc.) and actions (commands to run).
- Rules are evaluated from top to bottom. The first rule that matches runs its actions in order.
- A policy has to be trusted first, so modifications of a policy or its scripts do not go unnoticed.
Why choose PowerRules over scheduled tasks or systemd timers?
You can build the same thing yourself: a scheduled task which runs every few seconds and starts a script containing all the logic. PowerRules is essentially that script partially written. You describe what should happen instead of how to check it.
- Declarative: Combine conditions with
and,orandnotin a readable YAML file. - Portable: The same policy usually works on Windows, Linux and macOS.
- Debugging:
--dry-runshows what would happen and debug logs explain why a condition did or did not match.
For a single fixed schedule on one system, the built-in tools are usually the simpler choice.
Related¶
-
Create, validate, trust and run your first policy.
-
Match processes, windows, time and command results.
-
Run commands when a rule matches.
-
Detect modifications of policies and scripts.