DEV Community

delay.run
delay.run

Posted on Edited on

Moving cron jobs to a new server? A 12-point checklist so nothing runs twice, and nothing stops running

Reliable HTTP cron and delayed-job scheduling with automatic retries and full run logs — delay.run

Migrating to a new server is mostly about the application, the database and DNS. Scheduled jobs are an afterthought. Someone runs crontab -l > crontab.txt on the old box near the end, pastes it on the new one, and the migration is declared done.

Then the problems show up over the following weeks. The nightly invoice job runs on both servers and every customer gets two emails. The backup job is still running on the old server, which is about to be deleted, and backing up a database nobody uses anymore. The cleanup job that was in /etc/cron.d/ never moved at all.

Here's the checklist.

Inventory

1. Find every place schedules live, not just your crontab. On a typical Linux server that's:

for u in $(cut -d: -f1 /etc/passwd); do crontab -l -u "$u" 2>/dev/null | sed "s/^/$u: /"; done
cat /etc/crontab
ls -la /etc/cron.d /etc/cron.hourly /etc/cron.daily /etc/cron.weekly /etc/cron.monthly
systemctl list-timers --all
Enter fullscreen mode Exit fullscreen mode

Also look for application-level schedulers (Celery beat, Sidekiq-cron, a Node scheduler running inside the app), at jobs (atq), and anything in the hosting control panel.

2. Write down what each job does, who owns it, and what happens if it doesn't run. The last column is the important one. "Sends invoices" and "rotates a debug log" need very different care.

3. Note the environment each job depends on. Cron runs with a minimal environment. Jobs often rely on a PATH, a MAILTO, environment variables set at the top of the crontab, files in a home directory, credentials in a dotfile, or a specific working directory. List them per job.

4. Note the server's time zone. timedatectl on both servers. If the old box was in local time and the new one is in UTC, every job shifts by one or two hours the moment you move it, and by different amounts in summer and winter.

Move

5. Decide the cutover rule per job: "exactly one place, at all times". The two classic failures are "both servers run it" (double invoices, double emails, two backups fighting over a lock) and "neither runs it" (no invoices). Pick a cutover moment for each job, and disable on the old server in the same step as enabling on the new.

6. Comment out, don't delete, on the old server. Prefix each moved line with # MOVED to new-server 2026-11-20:. If you need to roll back, the line is there. If someone looks at the old server later, they know why it's quiet.

7. Install via files, not by hand. Put the crontab or timer units in version control and install them with your provisioning tool or crontab file.txt. Hand-pasted crontabs are how a migration loses the one line that was added directly on the old server last year.

8. Make jobs safe to overlap during the cutover. For jobs where running twice would hurt, add a lock that works across servers: a database advisory lock, or a row in a job_runs table with a unique constraint on job name and scheduled time. Then a brief overlap is harmless.

A migration is when scheduled jobs are most likely to run twice, or not at all, without anyone noticing. delay.run keeps the schedule outside your servers: it calls your HTTP endpoint on time, retries failures, and logs every run, so a server move doesn't touch the schedule.

Verify

9. Watch the first run of every job on the new server. Not "check tomorrow". Check the cron log for the start (grep CRON /var/log/syslog, or journalctl -u cron), the job's own output, and the result: was the backup file created, did the email go out?

10. Confirm the old server is quiet. After the cutover, the old server's cron log should show no job runs. If it's going to stay up for a while (for rollback), make sure nothing on it can still reach production systems with write access.

11. Check the first week, not just the first day. Weekly and monthly jobs won't run on day one. Put a reminder on the calendar for the first Monday, the first 1st of the month, and the first end of quarter after the migration.

Afterwards

12. Add a "did it run?" check for every job that matters. The best migration checklist still misses something. A heartbeat that each job pings when it finishes, with an alert when the ping doesn't arrive on time, catches the job that silently stopped. It's also exactly what you need for the next migration.

A note on mail

Many old cron setups rely on MAILTO and a local mail server to report job output. The new server may not have a mail transfer agent installed at all, so every error that used to arrive by email now vanishes. Check with a deliberately failing test job, and if you depend on cron mail, either install and configure a relay or, better, send job results to a log or chat channel you actually read.

The short version

  • Inventory every scheduler on the box, including timers and app-level schedulers.
  • Record environment, owner, time zone and impact of each job.
  • Exactly one place at all times: disable and enable in the same step.
  • Locks for jobs that must not overlap.
  • Verify first runs, then the first weekly and monthly runs.
  • Heartbeats for anything important.

If you'd rather the schedule didn't live on a server at all, an external HTTP scheduler like delay.run takes it out of the migration entirely: the next server move only changes where the endpoint lives.

Related reading

What's the job that got lost in your last server migration? Mine was a certificate renewal hook in /etc/cron.d/ that nobody knew existed.

Top comments (0)