---
title: "How to schedule tasks on a VPS with cron | StreetHosting"
description: "Automate backups, restarts and cleanups with cron on your Linux VPS. Learn the five time fields, create your first job and log its output to catch failures."
url: "https://streethosting.com.br/en/guides/vps/schedule-tasks-vps-cron"
type: "page"
language: "en-US"
---

VPS · 3 min · Intermediate

Published on Jun 17, 2026 · Updated on Jun 17, 2026

# Schedule tasks on a VPS with cron

A repetitive task you do by hand is a task you forget. Cron runs commands at fixed times: a backup overnight, a weekly cleanup, a scheduled restart. Here is how to set it up.

By [Equipe StreetHosting](https://streethosting.com.br/en/autores#equipe-streethosting) · StreetHosting infrastructure and support team

[Linux administration](https://streethosting.com.br/en/guides/topics/linux) [Automation and webhooks](https://streethosting.com.br/en/guides/topics/automation) [Backup and recovery](https://streethosting.com.br/en/guides/topics/backup)

Summarize with:

[](https://chat.openai.com/?q=Summarize%20the%20key%20points%20of%20this%20StreetHosting%20guide%3A%20https%3A%2F%2Fstreethosting.com.br%2Fen%2Fguides%2Fvps%2Fschedule-tasks-vps-cron.%20Highlight%20the%20step-by-step%20instructions%2C%20the%20prerequisites%20and%20the%20most%20common%20mistakes. "ChatGPT") [](https://claude.ai/new?q=Summarize%20the%20key%20points%20of%20this%20StreetHosting%20guide%3A%20https%3A%2F%2Fstreethosting.com.br%2Fen%2Fguides%2Fvps%2Fschedule-tasks-vps-cron.%20Highlight%20the%20step-by-step%20instructions%2C%20the%20prerequisites%20and%20the%20most%20common%20mistakes. "Claude") [](https://www.google.com/search?udm=50&aep=11&q=Summarize%20the%20key%20points%20of%20this%20StreetHosting%20guide%3A%20https%3A%2F%2Fstreethosting.com.br%2Fen%2Fguides%2Fvps%2Fschedule-tasks-vps-cron.%20Highlight%20the%20step-by-step%20instructions%2C%20the%20prerequisites%20and%20the%20most%20common%20mistakes. "Google AI Mode") [](https://x.com/i/grok?text=Summarize%20the%20key%20points%20of%20this%20StreetHosting%20guide%3A%20https%3A%2F%2Fstreethosting.com.br%2Fen%2Fguides%2Fvps%2Fschedule-tasks-vps-cron.%20Highlight%20the%20step-by-step%20instructions%2C%20the%20prerequisites%20and%20the%20most%20common%20mistakes. "Grok") [](https://www.perplexity.ai/search/new?q=Summarize%20the%20key%20points%20of%20this%20StreetHosting%20guide%3A%20https%3A%2F%2Fstreethosting.com.br%2Fen%2Fguides%2Fvps%2Fschedule-tasks-vps-cron.%20Highlight%20the%20step-by-step%20instructions%2C%20the%20prerequisites%20and%20the%20most%20common%20mistakes. "Perplexity")

Share:

[](https://x.com/intent/tweet?text=How%20to%20schedule%20tasks%20on%20a%20VPS%20with%20cron&url=https%3A%2F%2Fstreethosting.com.br%2Fen%2Fguides%2Fvps%2Fschedule-tasks-vps-cron "Share on X") [](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fstreethosting.com.br%2Fen%2Fguides%2Fvps%2Fschedule-tasks-vps-cron "Share on Facebook") [](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fstreethosting.com.br%2Fen%2Fguides%2Fvps%2Fschedule-tasks-vps-cron "Share on LinkedIn") [](https://wa.me/?text=How%20to%20schedule%20tasks%20on%20a%20VPS%20with%20cron%20https%3A%2F%2Fstreethosting.com.br%2Fen%2Fguides%2Fvps%2Fschedule-tasks-vps-cron "Share on WhatsApp")

For agents: Copy as Markdown [.md](https://streethosting.com.br/en/guides/vps/schedule-tasks-vps-cron.md)

In this guide 5 sections

* [What cron is](https://streethosting.com.br/en/guides/vps/schedule-tasks-vps-cron#o-que-e-cron)
* [The time fields](https://streethosting.com.br/en/guides/vps/schedule-tasks-vps-cron#campos-de-horario)
* [Your first task](https://streethosting.com.br/en/guides/vps/schedule-tasks-vps-cron#primeira-tarefa)
* [Common mistakes](https://streethosting.com.br/en/guides/vps/schedule-tasks-vps-cron#erros-comuns)
* [Practical uses](https://streethosting.com.br/en/guides/vps/schedule-tasks-vps-cron#usos-praticos)

Quick answer

**Cron**runs commands at fixed times on your VPS. Edit the user's crontab, write the five time fields (minute, hour, day, month and day of the week), point to the full path of the command and redirect the output to a log. It is the foundation of overnight backups, weekly cleanups and scheduled restarts.

## What cron is[](https://streethosting.com.br/en/guides/vps/schedule-tasks-vps-cron#o-que-e-cron)

Cron is the Linux task scheduler. You say what to run and when, and it handles the rest, even while you are logged out. It is the invisible engine behind routines like [automatic backups with restic](https://streethosting.com.br/en/guides/vps/vps-backup-restic-cron) and any repetitive maintenance.

## The time fields[](https://streethosting.com.br/en/guides/vps/schedule-tasks-vps-cron#campos-de-horario)

| Field            | Value   | Example use                  |
| ---------------- | ------- | ---------------------------- |
| Minute           | 0 to 59 | 0 for the start of the hour  |
| Hour             | 0 to 23 | 3 for three in the morning   |
| Day of the month | 1 to 31 | 1 for the first day          |
| Month            | 1 to 12 | every month with an asterisk |
| Day of the week  | 0 to 6  | 0 for Sunday                 |

## Your first task[](https://streethosting.com.br/en/guides/vps/schedule-tasks-vps-cron#primeira-tarefa)

1. Open your user's crontab for editing.
2. Write the line with the five fields and the command.
3. Use absolute paths for the command and files.
4. Redirect the output and errors to a log.

Start with a task that writes the date to a file every minute. Watching the file grow confirms that cron is working before you schedule anything important.

## Common mistakes[](https://streethosting.com.br/en/guides/vps/schedule-tasks-vps-cron#erros-comuns)

The number one mistake is assuming cron has the same environment as your terminal. It does not. Always use full paths and do not depend on variables that only exist in your interactive session.

## Practical uses[](https://streethosting.com.br/en/guides/vps/schedule-tasks-vps-cron#usos-praticos)

* Automatic backup during low-usage hours
* Cleanup of logs and temporary files
* Scheduled restart of services with advance notice
* Certificate renewal and maintenance tasks

For services that need to stay up and restart on their own after a crash, cron works alongside process management. See [PM2 and systemd to start services](https://streethosting.com.br/en/guides/vps/pm2-vs-systemd-nodejs). For the right machine, check out the lineup in [VPS plans](https://streethosting.com.br/en/vps).

In this guide

* [What cron is](https://streethosting.com.br/en/guides/vps/schedule-tasks-vps-cron#o-que-e-cron)
* [The time fields](https://streethosting.com.br/en/guides/vps/schedule-tasks-vps-cron#campos-de-horario)
* [Your first task](https://streethosting.com.br/en/guides/vps/schedule-tasks-vps-cron#primeira-tarefa)
* [Common mistakes](https://streethosting.com.br/en/guides/vps/schedule-tasks-vps-cron#erros-comuns)
* [Practical uses](https://streethosting.com.br/en/guides/vps/schedule-tasks-vps-cron#usos-praticos)

## Frequently asked questions

What are the five cron fields?

They are minute, hour, day of the month, month and day of the week. Each field accepts a single value, a list or a range. Together, they define the exact moment and the frequency at which the command runs.

Why does my task work in the terminal but not in cron?

Almost always it is a path or an environment variable. Cron runs in a lean environment, without the full PATH from your terminal. Use absolute paths for commands and files.

How do I know the task ran?

Redirect the output and errors to a log file on the cron line itself. Then you open the log and check whether the task ran and whether there was an error.

Can I use cron to restart game services?

Yes. Many servers schedule restarts during low-traffic hours to clear memory. Combine it with announcements to your players so nobody gets caught by surprise.

Next step

See VPS plans

Root VPS in Brazil with NVMe and Anti-DDoS.

[See VPS plans](https://streethosting.com.br/en/vps)

[See Ryzen VPS Ryzen 9 9950X VPS in São Paulo with root access, NVMe and gamer Anti-DDoS.](https://streethosting.com.br/en/vps/ryzen) [See Xeon VPS Xeon VPS for steady workloads, automation and long-running projects.](https://streethosting.com.br/en/vps/xeon)

## Related guides

[VPS Advanced How to automate VPS backups with restic and cron A backup that depends on you remembering does not work. With restic and cron you create encrypted snapshots, send them off the VPS, control retention and test restores without daily effort. 9 min Read guide](https://streethosting.com.br/en/guides/vps/vps-backup-restic-cron) [VPS Intermediate How to monitor VPS resources with htop and Netdata You only know you need a bigger plan once you can see the numbers. htop gives you a quick snapshot in the terminal, and Netdata gives you a full dashboard with CPU, RAM and disk history. 3 min Read guide](https://streethosting.com.br/en/guides/vps/monitor-vps-resources-htop-netdata) [VPS Intermediate PM2 vs systemd: keep your Node app always online on a VPS Your app needs to come back on its own after a crash and start together with the VPS. PM2 and systemd solve this in different ways. Here is how to set up each one and which to pick. 3 min Read guide](https://streethosting.com.br/en/guides/vps/pm2-vs-systemd-nodejs)

[← Back to the Guide Center](https://streethosting.com.br/en/guides)
