DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
VGSources
Blog

How to Schedule Routine Tasks With Cron and Anacron on a VPS

A practical VPS guide to cron and anacron: choose the right scheduler, configure root or user jobs, handle missed runs after reboot, and verify execution without duplicates.
Length10 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use cron when a task must run at a particular wall-clock time, such as a backup at 02:00 or a report at 06:30. Use anacron when a daily, weekly, or monthly task must eventually run even if the VPS was powered off at its scheduled time. Cron skips a missed instant; anacron records periodic completion and catches up after the machine returns.

This guide shows where root and user entries belong, how to configure both schedulers, how Debian’s systemd integration changes troubleshooting, and how to verify that jobs run only once with the intended permissions.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Cron and anacron solve different scheduling problems

Cron is a wall-clock scheduler. It evaluates entries at their specified minute, hour, date, and weekday while the operating system is running. If the VPS is stopped at that exact time, the cron invocation is missed; it is not replayed automatically when the server boots. The Red Hat Enterprise Linux System Administrator’s Guide summarizes this behavior: “A cron job is only executed if the system is running on the scheduled time.”

Anacron is a periodic catch-up scheduler. It tracks when each job last completed and runs it after the machine is available again. Red Hat describes the behavior this way: “If the system is not running at the scheduled time, an anacron job is postponed until the system is running.” A traditional anacron job can run at most once per day, so it is intended for daily-or-longer maintenance rather than minute-level polling.

#1 Best Overall
Sale
Gaoye Blue Light Blocking Glasses
  • BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
  • EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
  • COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
  • LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
  • WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.
Decision point Cron Anacron
Timing model Exact wall-clock fields (minute, hour, date, weekday) Elapsed periodic interval with a configurable startup delay
When the VPS is down The scheduled run is skipped The job is postponed and runs after the VPS returns
Typical shortest interval One minute in a standard five-field entry; practical intervals depend on workload One day for traditional anacron jobs
Best uses 02:00 backups, 06:30 reports, every-five-minute polling Daily log rotation, weekly cleanup, monthly maintenance
Primary configuration /etc/cron.d/, /etc/crontab, or a user’s crontab /etc/anacrontab
Privilege context Root files name a user; user crontabs run as their owner The system anacrontab is normally edited and run as root
Observability Daemon status, mail, redirected logs, and system journal Daemon or generated-timer logs, timestamps, mail, and redirected logs

Choose based on what failure means. A report that is useless after its intended time belongs in cron. A cleanup task that is still useful later belongs in anacron.

Choose the scheduler for the task

Use cron for time-sensitive work

Put a job in cron when its start time is part of the requirement. Examples include taking a database snapshot shortly before a maintenance window, polling an endpoint every five minutes, or generating a morning report at 06:30. Cron gives you the precise calendar expression, but you must accept that downtime at the scheduled instant means no run.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use anacron for maintenance that may catch up

Anacron is appropriate for jobs that need to happen once per period, not at a particular minute. Daily package-cache cleanup, weekly archival, and monthly accounting are common examples. If the VPS is rebooting or stopped during the nominal period, anacron waits until it is available and then applies the configured delay.

When neither behavior is sufficient

If a job must run at a precise time and also be recovered after downtime, do not silently substitute one scheduler for the other. Design an explicit recovery step, such as checking the last successful run from the job itself, and then decide whether cron plus that check or a native systemd timer better matches the requirement. On Debian systems, persistent systemd timers have behavior that differs from traditional anacron; inspect the actual timers before enabling overlapping mechanisms.

Prepare the VPS before creating a schedule

  1. Identify the distribution and service name. Red Hat-family systems commonly use the cronie package and crond.service. Debian-family systems use distribution-specific cron packages and commonly expose a service named cron. Follow the package documentation for the installed release rather than copying a package command from another distribution.
  2. Check that the scheduler is installed and running. On a system using the Red Hat service name, run:
    systemctl status crond

    If your distribution uses another name, substitute it. A service can be installed yet disabled, or enabled for boot but stopped in the current session.

  3. Confirm the clock and timezone. Cron evaluates the host’s local time. Check it with:
    timedatectl

    Verify the timezone, synchronization state, and daylight-saving expectations before choosing a calendar time.

  4. Prepare the command as the account that will run it. Confirm that the script exists, is executable, can read its inputs, and can write its output. Test it manually in that account before placing it in a scheduler.
  5. Decide where output will go. Cron can mail job output, but unattended VPS work is easier to diagnose when standard output and errors are redirected to a known log. Ensure the selected account can create or append to that file.

Understand cron’s two configuration forms

Cron has a five-field schedule, but system-wide files add a username field. Confusing these formats is a common cause of jobs that never run or run as the wrong account.

Location or command Fields Execution identity
/etc/crontab Minute, hour, day of month, month, day of week, username, command The username field selects the account
/etc/cron.d/<name> Minute, hour, day of month, month, day of week, username, command The username field selects the account
crontab -e Minute, hour, day of month, month, day of week, command The account that owns the crontab

The day-of-month and day-of-week fields have the usual cron calendar semantics provided by the installed implementation. Use an explicit, readable expression and test it rather than relying on a complicated combination of both fields.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Windex Gaming Cleaning Wipes, Pre-Moistened Wipes to Instantly Clean all Gaming Gear and Electronics, Resealable Packaging for a Freshness Lock, 25 count (Pack of 1)
  • WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
  • AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
  • PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
  • ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
  • COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed

Root job in /etc/cron.d/

For a service-wide task, create a descriptively named file in /etc/cron.d/. The Red Hat guide prefers this approach for a separately managed job because it avoids editing the distribution’s main file.

15 2 * * * root /usr/local/sbin/backup.sh >> /var/log/backup.log 2>&1

This means minute 15 of hour 2 every day, running as root. The command uses absolute paths and sends both output streams to a log. Keep the file owned by root and readable by the scheduler, and make the script executable:

chmod 750 /usr/local/sbin/backup.sh

Before relying on the schedule, run the script directly as root and verify the resulting files, permissions, and log entries.

Root job in /etc/crontab

You can place the same seven-field entry in /etc/crontab:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
15 2 * * * root /usr/local/sbin/backup.sh >> /var/log/backup.log 2>&1

Use one location for a given job. Defining it in both files creates duplicate executions.

User job with crontab -e

Log in as the intended account and run:

crontab -e

Add only five schedule fields followed by the command; do not add a username:

Rank #3
Sale
LISEN Cell Phone Stand Phone Holder for Desk, Office Decor Gadgets for Men
  • Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
  • Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
  • Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
  • ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
  • Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)
15 2 * * * /home/app/bin/backup.sh >> /home/app/logs/backup.log 2>&1

The job runs with that user’s privileges. It cannot read root-only inputs or write directories owned by another account. This is usually the safer choice for application data because a script compromise does not automatically grant root access.

Make cron jobs reliable and observable

Use an explicit environment

Cron starts jobs with a limited environment. Commands that work in an interactive SSH shell can fail because a binary is not on PATH, a required variable is absent, or the working directory is different. Call programs by absolute path and set required variables in the script or crontab. For example:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
15 2 * * * root /usr/local/sbin/backup.sh >> /var/log/backup.log 2>&1

Use the shell path supported by your distribution and script. If the script expects a particular directory, change to it explicitly inside the script instead of assuming an interactive working directory.

Capture both success and failure signals

Redirect standard output and standard error to a log or configure a mail destination for cron output. A silent job is difficult to distinguish from a successful one. Include a timestamped success message in the script’s own log when that helps operations, and arrange log rotation so an unattended task cannot fill the filesystem.

Match permissions to the execution user

Check every input, output directory, configuration file, and secret against the account that runs the job. Protect credentials from world-readable cron files and scripts. Test the exact command as the target user, not only as root; a root test can hide permission and environment problems that the scheduled account will encounter.

Configure anacron for catch-up execution

Edit /etc/anacrontab as root. Each job has four fields:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Ledagic IC+RGBW USB Powered Led Light Bar with App & Remote Control, 2 Pack
  • Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
  • Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
  • 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
  • Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
  • USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC
  1. Period: the interval in days.
  2. Delay: minutes to wait after anacron decides the job is due.
  3. Job identifier: a stable name used to record the job’s completion.
  4. Command: the program to execute.

Red Hat’s documented format is:

3 60 cron.daily /usr/local/bin/my-script.sh

This asks anacron to run the script every three days, waiting 60 minutes after it becomes due. Use an identifier that remains unchanged; changing it can make the scheduler treat the work as a new job.

Choose a delay deliberately

The delay prevents every deferred task from starting immediately at boot. Stagger heavy jobs so they do not compete with application startup, backups, or database recovery. The delay is measured in minutes and applies after anacron determines that the period has elapsed.

Use portable period syntax

The Debian anacrontab documentation for its systemd-cron implementation describes special tokens such as @daily, @weekly, and @monthly. It also notes that traditional anacron accepts only @monthly and @yearly. If the file must work across distributions or implementations, use numeric day periods and verify the installed manual before relying on a token.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Understand periodic limits

Traditional anacron runs a job no more than once per day. A weekly job therefore does not become a burst of seven executions after a week offline; it is one execution when due. Debian also documents a guaranteed minimum six-day gap for weekly anacron jobs. This is different from some persistent systemd timers, which can run at boot and again at the next calendar boundary.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Debian systemd-cron and duplicate execution

Some Debian configurations use systemd-cron to translate cron files into systemd timers. In that arrangement, inspect the generated timers rather than assuming that only a traditional cron daemon is involved. A native systemd timer with the same name takes precedence over the translated cron job.

Do not run systemd-cron alongside another cron daemon or anacron unless you have deliberately verified the interaction. Debian warns that doing so can execute the same scripts more than once. After editing /etc/anacrontab, inspect recent journal messages and generated timers:

Best Value
Sale
HUANUO FlowLift™ Dual Monitor Stand, Fully Adjustable Gaming Monitor Desk Mount for 13–32″ Computer Screens, Full Motion VESA 75x75/100x100 with C-Clamp & Grommet Base, Each Arm Holds 4.4 to 19.8 lbs
  • Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
  • Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
  • Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
  • Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
  • Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.
journalctl -n
systemctl list-timers

Look for the expected unit, next activation time, and most recent activation. If a native timer and a cron-derived timer both target the same script, disable one scheduling path before production use.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Verify a schedule before trusting it

Check the service state

For a Red Hat-style service, use:

systemctl status crond

Review whether it is loaded, enabled, and active. On another distribution, query that system’s cron service name. A disabled service will not start after reboot even if an entry is syntactically correct.

Inspect timers and journal output

On a Debian system using systemd integration, run:

systemctl list-timers
journalctl -n

These commands show whether cron or anacron files were translated, when a timer last fired, and whether the service reported an error. For ordinary cron installations, inspect the configured log destination and the system journal supplied by the distribution.

Test the command outside the scheduler

Execute the exact absolute command as its intended user. Confirm the exit status, output files, ownership, and log message. This isolates script defects from scheduler defects. If the command succeeds manually but fails on schedule, compare the environment, working directory, timezone, and permissions.

Troubleshoot common failure modes

Symptom Likely cause What to check
No execution at all Daemon is stopped or entry is in the wrong format Service status, file location, five versus seven fields, and journal messages
Runs as the wrong account A username was added to a user crontab, or omitted from a system file Use crontab -e without a username; include one in /etc/cron.d/ and /etc/crontab
“Command not found” or missing files Interactive shell environment is not present Absolute paths, explicit PATH, required variables, and working directory
Permission denied The scheduled user cannot read inputs or write outputs File ownership, mode bits, parent-directory permissions, and secret access
Expected run after reboot never appears Cron was used for a missed wall-clock instant Use anacron or a deliberately configured persistent timer for catch-up behavior
Job starts twice Duplicate entries or multiple scheduling daemons Search both system and user crontabs; inspect systemctl list-timers; avoid overlapping systemd-cron, cron, and anacron services
Job runs at an unexpected local time Timezone or daylight-saving assumption is wrong timedatectl, the VPS timezone, and the schedule’s intended region
Anacron runs later than expected Configured startup delay or a period that has not elapsed Period and delay fields, job identifier, last-completion record, and journal output

Practical schedule patterns

Nightly backup at a fixed time

When the backup must begin at 02:15, use a root cron entry:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
15 2 * * * root /usr/local/sbin/backup.sh >> /var/log/backup.log 2>&1

Document the timezone and verify that the backup script reports failure. If the VPS is down at 02:15, this entry does not replay the backup; choose anacron instead if eventual completion is acceptable.

Polling every five minutes

A time-sensitive polling command can use:

*/5 * * * * app /usr/local/bin/poll-endpoint

This seven-field form belongs in /etc/cron.d/ or /etc/crontab. In the account’s own crontab -e, remove app because the owner is implicit. Polling is a cron use case; anacron cannot provide five-minute cadence.

Maintenance every three days with catch-up

In /etc/anacrontab:

3 60 maintenance /usr/local/sbin/maintenance.sh

The job becomes due every three days, then waits up to the configured 60-minute delay before execution. If the VPS was offline when the period elapsed, anacron runs it after startup rather than discarding that period.

Operational checklist

  • Choose cron for an exact wall-clock time; choose anacron for periodic work that must catch up.
  • Confirm the installed distribution, scheduler package, service name, timezone, and clock synchronization.
  • Put root entries in /etc/cron.d/ or /etc/crontab with a username field.
  • Put per-user entries in crontab -e without a username field.
  • Use absolute command paths and define required environment variables.
  • Make scripts executable and verify read/write permissions as the scheduled account.
  • Redirect output or configure mail so failures are visible.
  • Use numeric anacron periods when portability matters; verify implementation-specific @ tokens.
  • On Debian systemd-cron systems, inspect journalctl and systemctl list-timers.
  • Remove duplicate definitions and avoid running overlapping cron, anacron, and systemd-cron schedulers.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.