Friday, January 10, 2025
HomeComputer ScienceCrontab in Linux

Crontab in Linux

crontab (cron table) is a command-line utility for scheduling automated tasks in Linux. It allows users to execute scripts or commands at specified times or intervals, enabling task automation.

Key Commands:
– View Crontab: crontab -l
– Edit Crontab: crontab -e
– Remove Crontab: crontab -r
– Edit for a Specific User: crontab -u username -e

See also  How to Create an Empty File in Linux | Touch Command

Syntax:

* * * * * command_to_execute
– – – – –
| | | | |
| | | | +— Day of the week (0 – 7)
| | | +—– Month (1 – 12)
| | +——- Day of the month (1 – 31)
| +——— Hour (0 – 23)
+———– Minute (0 – 59)

See also  How much do Computer Science professionals earn globally?

Examples:
1. Run a script daily at 5 AM:
0 5 * * * /path/to/script.sh
2. Delete logs every Sunday at midnight:
0 0 * * 0 rm -rf /var/log/*.log
3. Check a website every hour:
0 * * * * curl http://example.com

Crontab simplifies repetitive task management, enhancing productivity

RELATED ARTICLES
0 0 votes
Article Rating

Leave a Reply

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
- Advertisment -

Most Popular

Do Fish Have Hearts?

Top 10 comedy movies

Recent Comments

0
Would love your thoughts, please comment.x
()
x