Scheduling Redmine maintenance rake tasks

Redmine depends on several rake tasks that must run on a schedule to keep repositories, mail and housekeeping current. This page explains which tasks to schedule, how to run them with cron or systemd timers, and how to catch failures.

On this page

Which Redmine rake tasks teams schedule and why Redmine maintenance rake tasks matter

A self-hosted Redmine server does not stay tidy on its own. Attachments, API tokens and watcher records accumulate, repositories need their changesets fetched, reminder emails must go out on time, and incoming mail must be picked up for email-based issue creation. Redmine ships rake tasks that perform these jobs from the command line, so a server can run them on a timer instead of relying on an administrator to remember. Teams schedule them because the work is recurring, easy to forget, and visible to users when it stops: a missed reminder run or a repository that never refreshes looks like a Redmine fault even when the application is healthy.

Each task has its own purpose. Pruning tasks remove stale data such as old session or token records and orphaned watchers. Repository tasks fetch new commits so that changesets appear in issues and the repository browser. Reminder and mail receiving tasks run on a schedule by design, so they depend on the scheduler being correct. Before writing any cron entry or systemd timer, confirm the exact task names, arguments and environment variables in the Redmine version you have installed, using the rake -T listing on that server and the Redmine documentation for that release. Task names and options have changed between releases, and a schedule copied from an older guide can run the wrong task or fail silently.

Plan the schedule with the same care as the application. Decide which account runs each job, which Rails environment and working directory it uses, and where its output goes. Confirm that each task is safe to run while users are active and how often it should run for your volume of mail and repositories. The rest of this section covers the task-by-task choices, the scheduler options and how to alert on failures, but the starting point is an inventory: list every maintenance task your installed version provides, mark the ones your organization uses, and record who owns each one.

Which scheduled Redmine tasks fit which functions

This table compares the main scheduled Redmine maintenance task families by purpose, scheduling trigger and main trade-off. Read it to decide which jobs your deployment needs, then confirm exact task names and flags for your Redmine version before you write any cron entry or timer.

Task familyPurposeScheduling triggerMain trade-off
Attachment and token pruningRemoves expired API and session tokens and cleans up attachments no longer linked to any recordDaily or weekly, outside working hours, after a fresh backupDeleted files cannot be recovered without a backup, so confirm retention before the first run
Watcher cleanupRemoves watcher entries for users or issues that no longer exist or lost accessWeekly, or after large user imports or removalsCleanup changes notification recipients, so review a sample on a test copy first
Repository changeset fetchingImports new commits from linked SCM repositories into Redmine so browsing and issue linking stay currentFrequent interval or hook-triggered, sized to commit volumeShorter intervals keep history fresh but add load on the database and repository host, especially on large codebases
Issue remindersSends email reminders for issues with approaching or past due datesOnce a day at a fixed time that matches the team's time zoneReminders only send if mail delivery works, so a silent failure can go unnoticed without alerts
Incoming mail receivingCreates issues and notes from messages received by a mailbox or piped inputContinuous polling, or a scheduled run at a fixed intervalShorter intervals give faster issue creation but raise mailbox load and can duplicate work if runs overlap
Failure alerting (cron or systemd)Reports non-zero exit codes and missed runs from any of the above jobsEvery run, with a check that the last success is recentAlerts need a destination someone watches, and noisy alerts get ignored, so confirm the on-call route

Cron or systemd timers for Redmine scheduled jobs

Cron is the lowest-effort option and the one most Redmine administrators already know. A crontab entry names a schedule, a user and a command, and the scheduler starts a fresh process for each run. Because cron starts with a minimal environment, the job itself must set everything Redmine needs, usually by changing into the application directory, exporting the production environment and loading the Ruby version manager before calling the rake task.

  • Setup effort: One crontab line per task, usually in the crontab of the account that owns the Redmine files, or in /etc/cron.d/ with an explicit user field.
  • Environment handling: Put cd into the Redmine directory, set RAILS_ENV=production, and source the Ruby version manager (for example rbenv or RVM) inside a small wrapper script, since cron does not load your login profile.
  • Logging: Redirect output to a file with >> and 2>&1, and rotate that file yourself. Mail from cron goes to the local mailbox unless MAILTO is set.
  • Overlap protection: Cron has none by default. Wrap the command in flock so a slow run cannot start a second copy.
  • Missed runs: If the host is down at the scheduled time, the run is skipped and not retried.

Before you rely on a crontab entry, confirm that the job runs under the same user that owns the Redmine files and that the Ruby version used in the job matches the one the web server uses.

How to set up scheduled Redmine rake tasks

This sequence moves Redmine's maintenance tasks from ad hoc runs to a scheduler that runs them as the right user, without overlap, and with a record that survives the next upgrade. The result is a tested schedule with logs you can check and a document your team can follow.

  1. Confirm the install path and run-as user

    The engineer who runs the platform records the Redmine install directory, the Ruby and Bundler versions in use, the database configuration file, and the operating system account that owns the application files. Scheduled tasks must run as that account, or as a user with read access to the configuration and write access to the log and files directories. Confirm this with your own environment, since the layout depends on whether Redmine runs from a package, a Docker image or a manually installed host. The step is done when the team can state the exact user, directory and Ruby command that every later step will use.

  2. Test each task manually in production mode

    Run each maintenance task by hand from the Redmine directory with RAILS_ENV set to production, using the same user the scheduler will use. Typical candidates include pruning expired tokens, removing old attachments or orphaned files, cleaning up watchers, fetching repository changesets, sending issue reminders, and receiving mail if you use email-based issue creation. Check the task reference in the Redmine documentation for the exact task names in your version, and confirm the options each one accepts. Run tasks against a copy or a quiet period first if they delete data. The step is done when each task exits with a success status and the team has confirmed which tasks delete data.

  3. Record output and runtime for each task

    For every task that passed the manual run, capture the full command, the exit code, the start and end time, the output, and any warnings. Measure how long the task takes on production data and note whether runtime grows with the size of attachments or repositories. Keep this record with the schedule document so that a later slowdown can be compared against a known baseline. Ask your database and storage owners whether any task should run outside business hours or during a backup window. The step is done when each task has a one-line entry in the record with its command, its exit code and its observed runtime.

  4. Add each task to the scheduler with a lock

    Add one scheduler entry per task, using either cron or a systemd timer, and set each entry to run as the account confirmed earlier. Wrap each command in a locking tool such as flock so that a run which has not finished blocks the next one from starting, which prevents two copies of a long repository fetch from running at once. Redirect output to a log file with a name that identifies the task, and set the environment variables Redmine needs, including RAILS_ENV. The step is done when each scheduled entry is listed, its lock file exists, and a manual trigger of the scheduler produces the same output as the manual run.

  5. Configure failure alerts for each job

    Decide how a failed run reaches a person. With cron, this usually means sending output or a non-zero exit to a mail address or a monitoring system. With a systemd timer, the service unit can trigger a notification unit when it fails, and the journal records each run. Confirm that the alert channel works by forcing a harmless failure, such as pointing one job at a missing task name in a test copy, and checking that the alert arrives. Name an owner for each alert, so that a silent failure does not go unnoticed for weeks. The step is done when a forced failure produces a visible alert in the channel your operations team actually watches.

  6. Verify the first automated run in logs

    Wait for the first scheduled run of each task, then read its log file or journal entry and compare it with the manual record. Check the start time, the exit code, the output and the runtime, and confirm that the task changed what it should have changed, for example that tokens past their expiry are gone. Confirm also that the lock file was released after the run finished. If a run differs from the manual result, check the environment, the user and the working directory first, because these are the most common causes of scheduled-only failures. The step is done when every scheduled task has one successful logged run that matches its manual baseline.

  7. Document the schedule for upgrades

    Write a schedule document that lists each task, its exact command, its schedule, its lock file, its log location, its owner and its alert channel. Add the Redmine version the tasks were tested against, because task names and options can change between releases, and add a reminder to re-run the manual tests after each upgrade. Before any upgrade, confirm the new version's upgrade guidance and the plugin migration steps, since plugins may add or change maintenance tasks. Store the document with the Redmine configuration so it is reviewed together with other operational changes. The step is done when a colleague who did not build the schedule can find, run and verify each task from the document alone.

How scheduled tasks reach Redmine and report failures

The scheduler, either cron or a systemd timer, starts each rake task inside the Redmine application directory with the production environment. The task reads and writes the production database and attachment storage, while repository fetches pull from SCM sources and reminder or mail-receiving jobs talk to the mail server. Each run returns an exit status and writes to the production log, and that status is what your alerting channel should watch. Check that a failed run produces a non-zero exit code and a visible alert, not just a silent log line.

Scheduler, rake tasks, data sources and failure reporting on one Redmine host.

How to alert on failed Redmine maintenance jobs

A scheduled rake task that fails silently is worse than no schedule at all, because the team assumes attachments are pruned, tokens expire and changesets are fetched when none of that is happening. Alerting has to cover three failure modes: a non-zero exit, a run that never starts, and a run that starts and hangs. Each needs a different signal. Under systemd, a unit that exits non-zero enters a failed state, so an OnFailure= drop-in can start a small notification unit that carries the unit name and recent journal lines to the Redmine owners. Under cron, the job's standard output and errors are mailed to the address set in MAILTO only if the host has working local mail delivery, which many hardened servers do not. A wrapper script that records the exit status, sends a message on failure and writes a timestamp on success is the more portable option.

Missing runs and stalled jobs need a check that is independent of the job itself. A heartbeat service such as a push-based dead man's switch expects a ping after each successful run and alerts when the ping does not arrive within the expected window, which catches a timer that was disabled, a host that rebooted into a broken state, or a job blocked on a lock. Set the window from the schedule you chose, with margin for long runs such as repository fetching, and confirm the figure against your own runtimes rather than a default. Route alerts to the team that owns Redmine by naming that group in the notification target, not an individual's mailbox, and test the route with a deliberately failing job before go-live. Whether these channels are available depends on your mail relay, monitoring stack and on-call rules, so confirm them with the people who run those systems first.

Security and operational considerations for Redmine rake schedules

Scheduled rake tasks run unattended, often with more access than the people who maintain them realize. The cards below cover the identities, credentials, mailboxes, keys, logs and change records that connect every job on the schedule to the rest of the Redmine server.

Run jobs as a least-privilege user

Run each rake task as the same service account that owns the Redmine application files, and avoid root or a shared administrator login. That account should read the configuration and write only to the log, temporary and files directories Redmine needs. Confirm that the account cannot edit the application code, because a compromised job would otherwise be able to change what Redmine executes on the next start.

Protect database credentials used by jobs

Rake tasks read config/database.yml, so the file holds the same database password the web application uses. Restrict its permissions to the service account, keep it out of shared cron files and command lines, and check that job output never echoes connection details. Ask whether a separate read-write role is needed for pruning and whether it can be limited to the tables those tasks touch.

Handle the mail receiving account

Tasks that receive email, such as issue creation by email, need a mailbox with its own login. Use a dedicated account that only receives mail for Redmine, store its password outside the crontab, and confirm the mailbox is not shared with a person's inbox. Review who can read the mailbox, since messages may contain personal data and attachments that Redmine will import.

Scope repository keys for fetch jobs

Changeset fetch jobs authenticate to Git, Subversion or other repositories with deploy keys or service credentials. Give each repository its own read-only key where the host allows it, and store the private key with restricted permissions for the service account. Verify that the key cannot push, and rotate it when someone with access leaves the team.

Retain job output deliberately

Cron and systemd capture stdout and stderr, and those streams can record issue titles, user names and repository paths. Decide how long job logs stay on disk, rotate them, and restrict who can read them. Align the retention period with your data protection policy and check whether logs are shipped to a central service where access rules differ.

Control changes to schedule edits

A changed schedule can silently stop pruning, stop fetching or start mail processing at the wrong time. Keep crontab entries or timer units in version control, require review for edits, and record who changed them and why. After each change, confirm the next run time and the success of a manual test run before closing the change.

Questions teams ask before scheduling Redmine maintenance

Can our own team schedule Redmine maintenance tasks without an outside partner?

Yes, in most environments a team with Linux administration experience can schedule the rake tasks itself. The work is mostly configuration: choosing a scheduler, running each task as the account that owns the Redmine files, logging output and wiring up failure alerts. What usually takes more effort is deciding which tasks apply to your installation, testing them against a copy of production data and keeping the schedule correct through upgrades and plugin changes. Your team should confirm it has someone who can read Redmine's rake task documentation for the exact release in use, and that the person doing the work has time to test before anything runs unattended.

What makes Redmine maintenance effort larger or smaller?

Effort tracks how much the installation produces and depends on. The main drivers are:

  • Number of repositories linked to projects, since changeset fetching runs against each one and large histories take longer.
  • Mail volume, since reminders and incoming mail receiving add work and need monitoring for failures.
  • Installed plugins, because some plugins add their own rake tasks or change the behavior of existing ones, which must be checked after every upgrade.
  • Environment complexity, such as separate staging and production hosts, containers, offline networks or several Redmine instances on one server.

A small single-server installation with no repositories and no inbound mail is a short exercise. Each added driver adds testing and documentation work.

What does the team need to provide for this work?

The work needs a few specific inputs before scheduling starts:

  • Shell access to the Redmine host with an account that runs the application, and the ability to create cron entries or systemd unit and timer files.
  • A non-production copy of the Redmine database and files, so tasks can be run and timed before they are scheduled.
  • The list of installed plugins and their versions, plus the Redmine release in use. The Redmine download page lists which release lines are still supported, which affects how long the schedule will stay valid.
  • A named owner for failure alerts, and a mail route or monitoring tool that will receive them.

Someone also needs to approve retention choices for pruned data, because some tasks delete records that cannot be recovered without a backup.

How long does setting up Redmine maintenance scheduling usually take?

The duration depends on scope, and no fixed figure applies across installations. A single host with a few tasks, tested on a copy and documented, is far shorter than a setup with several repositories, plugins, mail receiving and alerting integrated with existing monitoring. Ask any provider, including your own team, to split the estimate into four parts: inventory of the installation, test runs on a copy, scheduler configuration with alerts, and handover documentation. Ask how many test cycles are included and whether a review follows the first scheduled week of runs. A written scope is the right basis for comparing estimates.

Should we use cron or systemd timers for Redmine rake tasks?

Either works, and the choice depends on what your host already uses. Cron is simple, widely understood and easy to read in a crontab, but it has weaker built-in logging and no native dependency handling. Systemd timers record each run in the journal, can express retries and resource limits in the unit file and can be made to fire an alert when a unit fails. Teams already running Redmine under systemd usually find timers easier to audit. Whichever you choose, keep the environment consistent: set the working directory, the Ruby and bundler paths and the Rails environment explicitly, because scheduled runs do not inherit an interactive shell.

How do we confirm that a scheduled Redmine task actually ran?

Check three things for each task: the scheduler recorded a start and exit status, the task's own output shows it completed, and the effect on data is visible. With cron, redirect output to a log file and check the exit code in monitoring. With systemd, use systemctl status and journalctl for the unit, and set the unit to fail visibly. For the effect, compare record counts or file sizes before and after a test run on your copy, and add a check that alerts when no successful run has been logged within the expected window. A missed run is the failure most teams notice last, so the silence check matters as much as the error alert.

What would an outside partner scope for Redmine maintenance scheduling?

A partner would normally scope the work in writing before starting. Expect the scope to cover an inventory of the installation including Redmine release, database, repositories, plugins and mail setup, a list of tasks to schedule with the reason for each, the scheduler choice and configuration, a test plan run against a copy, failure alerting integrated with your tools, and handover documentation. Ask whether plugin compatibility checks are included for upgrades, and whether ongoing support is a separate retainer. DeployOpen implements Redmine inside the client's own infrastructure and provides fixed-scope engagements, with scope, deliverables and timelines agreed in writing before work starts. A quote follows from that written scope.

Which Redmine version should the schedule be built against?

Build and test the schedule against the release you intend to keep running, and confirm that it is still supported. According to the Redmine download page, 7.0.x is the fully supported line, 6.1.x receives only bug fixes and security updates, 6.0.x receives only important security updates, and 5.1.x and older are unsupported. Rake task names and options can change between releases, so a schedule written for an older line should be re-tested after an upgrade. Record the release number alongside the schedule documentation so the next person knows which behavior to expect.

How DeployOpen scopes and supports Redmine scheduled maintenance

DeployOpen scopes scheduled maintenance for Redmine as a fixed-scope engagement with the work agreed in writing before anything is changed on your server. The written scope names each rake task that will run, the account it runs under, the scheduler used (cron or systemd timers), the working directory and environment, and the alert route for failures. It also states what is out of scope, such as changes to retention rules that your records or legal team has not yet approved. Because most of the risk sits in the details of your install, the scope is built from a walkthrough of your current Redmine version, database, plugins and repository setup, and it is confirmed with the people who own backups, mail and on-call response.

Testing and documentation follow the same written plan. Each scheduled task is run by hand first in a non-production copy, and its output and runtime are recorded so that the first scheduled run can be checked against a known baseline. Failure alerting is tested by forcing a controlled failure and confirming that the message reaches the people named in the scope. The deliverables typically include the crontab or timer units, a short runbook describing what each job does and what a failure looks like, and a change record for the environment. Confirm with DeployOpen exactly which of these items your scope includes, since the list depends on your environment and agreed deliverables.

Once the engagement closes, many teams choose a retainer for ongoing support. A retainer can cover monitoring of scheduled job results, review after each Redmine upgrade (the upgrade procedure in the Redmine upgrade guide includes database migrations that can change task behavior), and adjustments when plugins are added or removed. Ask any provider to state in the quote what is covered, how alerts are triaged, and who responds outside working hours. Pricing and response terms are set in the written quote for your scope. DeployOpen does not publish a price list, so the quote follows from the scope you agree.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.