CloudsArk
Commands Linux

crontab Command Examples in Linux

Practice useful crontab command examples for everyday Linux administration and troubleshooting.

crontab Command Examples in Linux

Introduction

These examples show practical ways to use crontab on a Linux terminal. Each example is written so you can adapt it for administration or troubleshooting.

Example 1: Basic Usage

crontab -l

This is the simplest form of the command and is a good starting point before adding options.

Example 2: Common Admin Task

crontab -e

This example reflects a common task on RHEL, Rocky Linux, AlmaLinux, or similar systems.

Example 3: Useful Option

sudo crontab -u apache -l

This option helps narrow the result, change behavior, or handle a more realistic target.

Example 4: Real-World Scenario

crontab -r

Use this pattern when the task moves beyond a single basic command.

Example 5: Verification

systemctl status crond

Example output:

0 2 * * * /usr/local/bin/backup.sh

Common Mistakes

  • Forgetting cron has a limited environment and PATH.
  • Using crontab -r without backing up the current schedule.
  • Expecting cron output to appear on the terminal instead of mail or logs.

Quick Reference

crontab -l
crontab -e
sudo crontab -u apache -l
crontab -r
systemctl status crond

Summary

Good crontab usage means choosing the right option, keeping the target clear, and verifying the result with output you can explain.