Linux Terminal Command: cron
The cron command is an essential tool in System Services & Scheduling. In this tutorial, we will explore what cron does, look at everyday examples, and cover advanced options to supercharge your command-line workflow.
Concept & Explanation
The cron daemon executes commands on a recurring schedule configured in files called crontabs.
Common Options & Syntax
cron [options] [arguments]
Here are the most common flags used with cron:
- Simple Usage: Basic default commands.
- Detailed View: Shows diagnostic information.
- Advanced Actions: Can chain parameters for scripting.
1. Interactive Example (Simple)
Here is how most people run the command:
# Example
crontab -l
What it does: Lists active cron jobs for the current user.
2. Power-User Example (Advanced)
For scripting and advanced diagnostics, use this configuration:
# Advanced
crontab -e
What it does: Opens your user crontab config file (e.g. 0 4 * * * /backup.sh runs a script daily at 4:00 AM).
⚙️ Warning & Common Pitfalls
[!WARNING] Cron running environment uses a minimal
$PATH. Always specify absolute executable paths in your scripts (e.g., use/usr/bin/tarinstead oftar).
🔗 Related Commands
Here are some related posts on cli_tty1 you might want to check out:
- tar : Tape archiver utility.