If you have scripts that need to run periodically, you might rely on tools like crontab or systemd timers. However, if your machine doesn’t run 24/7 -- as is often the case with laptops -- crontab may miss scheduled tasks if the system is off at the designated time. While systemd timers offer a more robust solution, they require a more complex setup and aren’t available on all Linux distributions.
Anacron is a viable option, but it lacks the capability to monitor whether jobs have successfully completed or failed.
Fcron offers a wide range of features, though setting it up requires some extra time.
Simplecron, on the other hand, provides a straightforward, lightweight alternative that requires only Ruby and Cronie. It reliably manages periodic tasks and handles scheduled jobs differently based on their exit codes, distinguishing between successful and failed executions (see Logging and Error Handling).
Simplecron leverages Cronie (crontab) to mimic a service functionality. Once enabled (see Usage below), crontab triggers Simplecron every minute, and Simplecron, in turn, manages your scheduled tasks (see Setup below). It’s as simple as that.
-
Install
cronieand enable its service. -
Install
ruby. -
Download the
simplecronscript, make it executable, and copy it to yourPATH.
-
Create the file
~/.config/simplecron/config(you will need to create the enclosingsimplecronfolder as well). -
Check the shipped
config-examplein order to create yours. Each line is a job (no blank lines allowed) in the format:
task, period, mode, command
task is simply a control name for your jobs and can be any value.
period specifies the interval between job executions (refer to config-example).
mode defines how elapsed time is calculated, with two options: clock and uptime.
-
clockuses the system time from thedatecommand, which reflects the actual time. -
uptimemeasures only the time the computer was actively running, excluding sleep periods.
command is any valid system command that your environment supports.
- Lines containing hashtags (
#) anywehre are ignored.
Syntax: simplecron [COMMAND]
COMMANDS: status, enable, disable, and run.
status: Tells if simplecron is enabled or disabled.
enable / disable : enable / disable simplecron per user.
run: execute all tasks from ~/.config/simplecron/config serialized.
Normaly run is not intended to be used manually but through a crontab,
activated by the simplecron enable command.
Running simplecron has the same affect of running simplecron status.
Logs are kept on ~/.cache/simplecron.
Simplecron monitors the exit codes of tasks to handle failures intelligently. If a task returns a non-zero exit code (indicating failure), Simplecron will retry it every 10 minutes for up to an hour. If the task continues to fail, retries become less frequent, occurring every hour until it completes successfully, i.e., until Simplecron receives an exit code of 0.