Split View: CronTab 이란?
CronTab 이란?
CronTab이란?
CronTab은 유닉스, 리눅스, 맥OS 등의 운영 체제에서 사용되는 작업 예약 프로그램입니다. 일정 시간마다 실행될 커맨드나 스크립트를 정의할 수 있어서, 자동적으로 실행될 작업을 관리할 수 있도록 도와줍니다. 일반적으로는 백업, 로그 파일 삭제, 서버 데이터 정리 등 반복적인 작업을 자동화할 때 사용됩니다.
CronTab 예제
30 2 * * * /usr/bin/find
은 매일 새벽 2시 30분에 /usr/bin/find 명령을 실행하라는 뜻입니다.
5 4 * * 1-5 /usr/local/bin/script.sh
는 월요일부터 금요일 새벽 4시 5분에 /usr/local/bin/script.sh를 실행하라는 뜻입니다.
0 4 * * 0,6 /usr/local/bin/weekend.sh
는 주말 새벽 4시에 /usr/local/bin/weekend.sh를 실행하라는 뜻입니다.
자세한 내용은 man crontab 명령어를 이용하여 확인하실 수 있습니다.
CronTab 문법
https://crontab.guru/ 에서 crontab expression의 의미를 확인할 수 있습니다.
CronTab 문법은 다음과 같습니다.
* * * * * command
- - - - -
| | | | |
| | | | ----- Day of week (0 - 7) (Sunday = both 0 and 7)
| | | ------- Month (1 - 12)
| | --------- Day of month (1 - 31)
| ----------- Hour (0 - 23)
------------- Minute (0 - 59)
What is CronTab?
What is CronTab?
CronTab is a task scheduling program used in operating systems such as Unix, Linux, and macOS. It allows you to define commands or scripts to be executed at regular intervals, helping you manage tasks that need to run automatically. It is commonly used to automate repetitive tasks such as backups, log file deletion, and server data cleanup.
CronTab Examples
30 2 * * * /usr/bin/find
This means to execute the /usr/bin/find command every day at 2:30 AM.
5 4 * * 1-5 /usr/local/bin/script.sh
This means to execute /usr/local/bin/script.sh at 4:05 AM from Monday to Friday.
0 4 * * 0,6 /usr/local/bin/weekend.sh
This means to execute /usr/local/bin/weekend.sh at 4:00 AM on weekends.
For more details, you can check using the man crontab command.
CronTab Syntax
You can check the meaning of crontab expressions at https://crontab.guru/.
The CronTab syntax is as follows.
* * * * * command
- - - - -
| | | | |
| | | | ----- Day of week (0 - 7) (Sunday = both 0 and 7)
| | | ------- Month (1 - 12)
| | --------- Day of month (1 - 31)
| ----------- Hour (0 - 23)
------------- Minute (0 - 59)
Quiz
Q1: What is the main topic covered in "What is CronTab?"?
What is CronTab?
Q2: What is CronTab Examples?
This means to execute the /usr/bin/find command every day at 2:30 AM. This means to execute
/usr/local/bin/script.sh at 4:05 AM from Monday to Friday. This means to execute
/usr/local/bin/weekend.sh at 4:00 AM on weekends.
Q3: Explain the core concept of CronTab Syntax.
You can check the meaning of crontab expressions at https://crontab.guru/. The CronTab syntax is
as follows.