https://cjh5414.github.io/linux-crontab/
예약된 작업 리스트
현재 예약된 작업의 리스트를 보여준다.
$ crontab -l
예약된 작업 수정
새로운 작업을 추가하기 위해서는 -e 옵션을 이용한다. 특정 파일을 통해 관리 하는데 default로 주석에 사용하는 방법이 나와있다. 맨 아래에 원하는 명령을 입력하고 저장하면 된다. 다시 명령을 실행하면 이전의 내용을 수정, 추가할 수 있다.
$ crontab -e
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
작업 리스트 삭제
-e 옵션으로 추가한 작업 명령이 삭제된다.
$ crontab -r
작업 명령 이용 방법
아래와 같은 형식으로 예약 명령어를 이용한다. 예시로 이해하는 것이 훨씬 쉽다.
* * * * * 수행할 명령어
┬ ┬ ┬ ┬ ┬
│ │ │ │ └───────── 요일 (0 - 6) (0:일요일, 1:월요일, 2:화요일, …, 6:토요일)
│ │ │ └───────── 월 (1 - 12)
│ │ └───────── 일 (1 - 31)
│ └───────── 시 (0 - 23)
└───────── 분 (0 - 59)
예시
* * * * * /home/user/test.sh
- 1분 마다
/home/user/test.sh를 수행.
30 10,22 * * * /home/user/test.sh
- 매일 오전 10시 30분, 오후 10시 30분에
/home/user/test.sh를 수행.
*/10 * * * * /home/user/test.sh
- 10분 마다
/home/user/test.sh를 수행.
##
0 8 * * 1-5 /home/user/test.sh
- 평일(월~금요일) 8:00 시에
/home/user/test.sh를 수행.
timezone 변경
사용 중인 OS의 timezone이 맞지 않으면 crontab이 원하는 시간에 실행되지 않을 수 있다. $ date 명령으로 확인해보고 맞지 않으면 timezone을 변경해줘야 한다.
$ date
Wed Jun 7 23:41:57 KST 2017
timezone을 변경하는 방법은 아래의 링크를 참고하면 된다.
timeznoe 을 변경한 후에는 crontab을 재시작 해야 적용된다.
$ service cron restart
참고자료
댓글 0
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
|---|---|---|---|---|
| 71 | 포트 상태 확인 및 포트 열기 | proin | 2018.06.05 | 0 |
| 70 | [WEB] 회원가입 부분 기본 틀 | proin | 2018.06.04 | 1 |
| 69 | MySQL 패스워드 변경 | proin | 2018.06.01 | 0 |
| 68 | DB계정 관련 | proin | 2018.06.01 | 2 |
| 67 | html 문서에서 php 코드가 실행이 안될 때 | proin | 2018.05.29 | 3 |
| 66 | onclick 링크 (새창/팝업/현재창/프레임) | proin | 2018.05.29 | 0 |
| 65 | [WEB] DIV 태그를 이용하여 레이아웃 만들기 | proin | 2018.05.28 | 0 |
| 64 | MySQL 숫자 | proin | 2018.05.28 | 0 |
| » | crontab 명령어 | proin | 2018.05.27 | 1 |
| 62 | MySQL Database Dump 명령 | proin | 2018.05.27 | 0 |
| 61 | [WEB] css 버튼 디자인 모음 | proin | 2018.05.23 | 0 |
| 60 | [WEB] 제타위키 세션 PHP 로그인 | proin | 2018.05.23 | 0 |
| 59 | [WEB] 세션 PHP 로그인 | proin | 2018.05.23 | 2 |
| 58 | PHP를 이용한 Header 페이지 이동(리다이렉트Redirect) | proin | 2018.05.21 | 0 |
| 57 | [아두이노] 블루투스로 컨트롤하는 무선조종 자동차 | proin | 2018.05.21 | 1 |
| 56 | [아두이노] Arduino MEGA 핀배열 | proin | 2018.05.21 | 3 |
| 55 | [아두이노] DC 모터 조이스틱 속도 제어 | proin | 2018.05.16 | 1 |
| 54 | [아두이노] DC 모터의 속도제어(모터드라이버 L298N) 2편 | proin | 2018.05.14 | 4 |
| 53 | How to Use the Arduino Joystick Shield v2.4 | proin | 2018.05.14 | 0 |
| 52 | Joystick Shield Module V1.A | proin | 2018.05.14 | 0 |