Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk10 min

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

A practical VPS guide to cron and anacron: choose the right scheduler, write root and user entries correctly, configure catch-up maintenance, and prevent missed or duplicate runs.
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 the task must happen periodically but the exact minute is unimportant: if the VPS is powered off at the planned time, anacron runs the job after the system returns. Cron jobs that fall during downtime are skipped.

This guide shows where root and user schedules belong, how to write each file, how to make jobs observable, and how to avoid duplicate execution on distributions that translate cron files into systemd timers.

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 checks the current date and time and starts a command when the five time fields in a schedule match. Red Hat’s Enterprise Linux System Administrator’s Guide summarizes the limitation precisely: “A cron job is only executed if the system is running on the scheduled time.” A VPS reboot, shutdown, or outage at that instant means that occurrence is lost.

Anacron is a periodic catch-up scheduler. It tracks whether a periodic job has completed and postpones it when the machine is unavailable. 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 given anacron job runs no more than once per day, even if its period or other conditions might otherwise cause more frequent execution.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.
Concern Cron Anacron
Timing model Specific minute, hour, date, and weekday combinations Periodic interval with a startup delay
When the VPS is down The occurrence is skipped The job is deferred and runs after the system is available
Minimum repeat behavior Can run every minute, subject to the schedule At most once per day for each job
Typical uses 02:00 backups, 06:30 reports, five-minute polling Daily, weekly, or monthly maintenance where eventual completion matters
Configuration /etc/cron.d/, /etc/crontab, or a user crontab /etc/anacrontab and the implementation’s supporting files
Privilege Root files name a user; user crontabs run as their owner The system anacrontab is normally edited as root and runs with the configured system context
Observability Daemon status, mail, logs, and redirected output Daemon or generated-timer logs, anacron state, mail, and redirected output

Choose based on the failure you are willing to accept. Missing a precise 02:00 window points to cron. Missing an entire day of maintenance because the VPS was rebooting points to anacron or a persistent systemd timer.

Before creating a schedule

Identify the distribution and scheduler implementation

Package names and service names differ between Linux families. On Red Hat-based systems, the documented prerequisites install the cronie package, enable crond.service, and start it for the current session. Debian-family systems use their own package and service conventions, so follow the distribution’s package documentation rather than copying the Red Hat package command.

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.

Check the running services before adding entries:

systemctl status crond
systemctl status cron

One of those names may not exist on your VPS. The status command that succeeds identifies the service name used by that installation. If your distribution uses systemd-cron, also inspect the generated timers:

systemctl list-timers --all

Do not assume that a file has been activated merely because it was saved. Confirm that one scheduler is reading it and that the service is enabled for future boots.

Decide which account should run the command

Write down the least-privileged account that can read the inputs and write the outputs. A backup that needs access to protected system directories may require root; an application export should usually run as the application account. The account determines file permissions, environment variables, network credentials, and the location of user-owned files.

Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.

Set up a root cron job

For a system-wide job, create a file in /etc/cron.d/ (the preferred location in the Red Hat guide) or edit /etc/crontab. These formats have six scheduling columns: minute, hour, day of month, month, day of week, and username, followed by the command.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Position Allowed values Meaning
Minute 0-59 Minute within the hour
Hour 0-23 Hour in the 24-hour clock
Day of month 1-31 Calendar day
Month 1-12 or names supported by the implementation Month of the year
Day of week 0-7 or names supported by the implementation Weekday; implementations commonly treat 0 and 7 as Sunday
Username An existing local account User whose privileges execute the command

A nightly root backup at 02:15 can be represented as:

15 2 * * * root /usr/local/sbin/backup.sh

Save it as a clearly named file such as /etc/cron.d/nightly-backup. The file’s command must use an absolute path. Keep one logical job per file when practical; that makes ownership, review, and removal safer.

Use the correct syntax for a user crontab

Run crontab -e while logged in as the intended account, or explicitly select that account through your administration procedure. A user crontab has only the five time fields and the command; it does not contain a username column:

15 2 * * * /home/app/bin/backup.sh

Putting root in this format shifts every field and produces an invalid or dangerous schedule. Conversely, omitting the username in /etc/cron.d/ can cause the file to be rejected or interpreted incorrectly.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by

Common schedule expressions

Purpose Entry pattern
Every five minutes */5 * * * * app /path/to/poll in a system file, or omit app in that user’s crontab
At 06:30 every day 30 6 * * * app /path/to/report
At 02:00 every Sunday 0 2 * * 0 app /path/to/weekly-task
On the first day of each month at 03:10 10 3 1 * * app /path/to/monthly-task

Use the syntax accepted by your cron implementation for names and special shortcuts. Numeric fields are the most portable choice. Review schedules involving both day-of-month and day-of-week carefully; implementations can treat those two fields as an inclusive match rather than requiring both, so test the actual dates your command will run.

Make cron jobs reliable and observable

Define the execution environment

Cron is not an interactive shell session. Set a predictable shell and path in a system cron file when needed, and do not rely on aliases, interactive profile files, or a working directory:

SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
[email protected]
15 2 * * * root /usr/local/sbin/backup.sh

Use the real mail destination in your environment; the example domain is only a placeholder. If a job needs application variables, define them explicitly or load a controlled environment inside the script. Use absolute paths for interpreters, utilities, input files, and output files.

Capture output and errors

Unobserved failures are the most common cron problem. Redirect standard output and standard error to a log that the job’s account can write:

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.
15 2 * * * root /usr/local/sbin/backup.sh >>/var/log/nightly-backup.log 2>&1

Alternatively configure mail with MAILTO and ensure the VPS has a working local mail transport. Do not redirect everything to /dev/null until you have another way to detect failures.

Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.

Check permissions and secrets

  • Make the script executable, for example with chmod 750 /usr/local/sbin/backup.sh, and verify that the scheduled account can traverse every parent directory.
  • Give the account write access to the destination but not broader access than required.
  • Keep passwords, API keys, and private keys out of world-readable cron files and command lines. Store them in a protected configuration file or secret mechanism readable only by the job’s account.
  • Run the command manually as the target account before scheduling it. This catches missing permissions and path assumptions without waiting for the next run.

Configure anacron for catch-up work

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

  1. Period: the interval in days.
  2. Delay: minutes to wait after anacron starts before launching the command.
  3. Job identifier: a stable name used to track the job.
  4. Command: the full command to execute.

This entry runs the script every three days, waiting 60 minutes after the scheduler becomes active:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
3 60 cron.daily /usr/local/bin/my-script.sh

The delay is useful when many services start together after boot or when you want routine maintenance away from the initial recovery workload. Keep the identifier stable; changing it can make the scheduler treat the entry as a new job.

Special period tokens and portability

The Debian systemd-cron implementation documents tokens including @daily, @weekly, and @monthly. It also notes that traditional anacron accepts only @monthly and @yearly. If a schedule must move between distributions, use numeric day periods or verify the exact implementation first. Do not assume a token accepted by a generated systemd timer is accepted by a standalone anacron daemon.

Choose a delay and interval deliberately

Use anacron for work whose completion matters more than an exact timestamp: filesystem cleanup, certificate or cache maintenance, periodic reports, and other daily, weekly, or monthly tasks. A weekly anacron job has a guaranteed minimum six-day gap according to Debian’s documentation. That prevents repeated execution during a short outage-and-reboot cycle, but it also means an anacron entry is not a substitute for a five-minute poller or a precise deadline.

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

Handling downtime, reboots, and systemd integration

What happens after a missed cron time

Cron does not queue an occurrence that happened while the VPS was off. If the machine was down at 02:00, a 0 2 * * * job waits until the next scheduled 02:00. If that lost run is unacceptable, redesign the task as an anacron period or as a persistent systemd timer, then make the script safe to run after a long delay.

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

What happens after a missed anacron period

Anacron records periodic completion and runs the pending job when the machine returns, subject to its configured delay. It is therefore appropriate for “at least once per period” maintenance, not for a guaranteed minute. The command should be idempotent: running it after a delayed boot should produce a correct result rather than corrupting partially completed work.

Debian systemd-cron caveats

On Debian systems using systemd-cron, cron files can be translated into systemd timers. Native systemd timers take precedence over cron jobs with the same name. Debian also warns that running systemd-cron alongside another cron daemon or anacron can execute scripts more than once. Pick one scheduling path for each job and disable the competing daemon or entry.

After editing /etc/anacrontab, inspect recent messages and generated timers:

journalctl -n
systemctl list-timers --all

For a persistent systemd timer, Debian notes that a timer may run at boot after downtime and then again at the next calendar boundary. That behavior differs from an anacron weekly job’s minimum six-day spacing, so choose the mechanism whose catch-up semantics match the task.

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

Verify a schedule before trusting it

  1. Validate the file location and syntax. Confirm whether the entry is in /etc/cron.d/, /etc/crontab, a user crontab, or /etc/anacrontab. Count the fields and check the username column rules.
  2. Check the service. Run systemctl status crond or the distribution’s cron service name. Ensure it is enabled for boot and active now.
  3. Check generated timers. On systemd-cron installations, run systemctl list-timers --all and confirm the expected unit and next trigger.
  4. Inspect logs. Use journalctl for service and timer messages. Review the job’s own log or mail output for the command’s exit status and error text.
  5. Test as the target account. Execute the exact absolute command with the same account, environment, and working-directory assumptions. Do not test only as an interactive administrator.
  6. Test the downtime policy. For anacron or a persistent timer, verify behavior on a disposable VPS or maintenance window by stopping the service or rebooting, then checking that one catch-up run occurs. Do not induce an outage on a production machine merely to test scheduling.

Troubleshoot the common failure modes

The job never runs

  • The daemon is stopped or the wrong service name was checked. Verify the active service with systemctl status.
  • The file has the wrong number of fields, especially a missing username in /etc/cron.d/ or an extra username in a user crontab.
  • The command path is relative, the script is not executable, or its interpreter line points to a nonexistent path.
  • The schedule uses a timezone different from the one you expected. Confirm the VPS timezone and express the schedule in that timezone, or use a scheduler configuration that explicitly supports the required timezone.

The job runs manually but fails under cron

  • Set PATH and other required variables explicitly.
  • Replace relative paths with absolute paths and choose a working directory inside the script.
  • Check read, execute, and write permissions for the scheduled account.
  • Read the redirected log and service journal; cron’s non-interactive shell will not show prompts or terminal-only output.

The job runs twice

  • Look for the same command in a user crontab, /etc/crontab, and /etc/cron.d/.
  • On Debian, check whether systemd-cron is translating the file while a separate cron daemon or anacron is also active.
  • Check for a native systemd timer with the same purpose. Disable one scheduling path and retain a single owner.
  • Add a lock or an in-progress check inside long-running scripts so an overlap cannot corrupt output while you correct the schedule.

A supposedly missed job does not catch up

That is expected for ordinary cron. Replace it with an anacron entry or a persistent systemd timer if eventual execution is required. Then confirm the implementation’s period, delay, state tracking, and generated timer behavior rather than assuming all “persistent” schedulers use the same rules.

A practical decision checklist

  • Use cron for a precise wall-clock event: a report at 06:30, a backup window at 02:00, or polling every five minutes.
  • Use anacron for daily, weekly, or monthly maintenance where one completed run per period is enough and a reboot should not lose the work.
  • Use a systemd timer when your distribution already standardizes on native systemd units and you need its documented persistence and timer inspection tools.
  • Put privileged system jobs in /etc/cron.d/ or /etc/crontab with an explicit username; put account-specific jobs in that account’s crontab -e without a username.
  • Use absolute paths, explicit environment settings, protected secrets, and visible logs for every scheduler.
  • Before production, verify the service, generated timer, permissions, timezone, and catch-up behavior on the actual VPS distribution.

The reliable design is the one whose downtime behavior matches the business requirement: cron preserves timing but can skip work, while anacron sacrifices the exact minute to preserve periodic completion.

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.

Leave a Reply

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

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

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

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.