#Try
#작성법
crontab -e
#list 확인 방법
crontab -l
# 매 10분마다 temp 폴더에 CPU의 온도를 temp-cpu.txt 파일로 저장하는 명령어
*/10 * * * * vcgencmd measure_temp >> /var/www/html/temp/temp-cpu.txt
# 매일 4시 정각에 시스템 리부팅 ; sudo 및 reboot 위치는 whereis 명령어 사용하여 위치상이시 변경해야함
0 4 * * * /usr/bin/sudo /sbin/reboot -h 0
# 매월1일 4시 3분에 sql data 백업, ID는 root 이고 비밀번호는 PASSWORD
3 4 1 * * sudo mysqldump -u root -pPASSWORD --all-databases | gzip > /home/pi/backup/backup.heeseop.mysql-`/bin/date +\%Y\%m\%d\%H\%M`.sql.gz
# 매월1일4시7분에 "/var/www"하위폴더 를 압축백업
7 4 1 * * sudo /bin/tar zcvf /home/pi/backup/backup.heeseop.www-`/bin/date +\%Y\%m\%d\%H`.tar.gz /var/www/
#재부팅시 300초(=5분) 대기 후 다시 재부팅 실행(&&) = 무한부팅
@reboot sleep 300 && /usr/bin/sudo /sbin/reboot -h 0
@reboot sleep [time in seconds] && [path to job]
#분(minute) 시(hour) 날(day) 달(month) 요일(dayofweek)
m(분) : 0~59
h(시) : 0~23
dom(일) : 1~31
mon(월) : 1~12
dow(요일) : 0~7 ( 0 일 1 월 2 화 3 수 4 목 5 금 6 토 7 일 )
@reboot = run at boot and reboot only
@yearly = run at midnight Jan 1 each year (equiv to 0 0 1 1 *)
@annually = run at midnight Jan 1 each year (equiv to 0 0 1 1 *)
@monthly = run at midnight on the first day of each month (equiv to 0 0 1 * *)
@weekly = run at midnight each Sunday (equiv to 0 0 * * 0)
@daily = run at midnight each day (equiv to 0 0 * * *)
@ midnight = run at midnight each day (equiv to 0 0 * * *)
@ hourly = run on the first second of every hour (equiv to 0 * * * *)
#1월 1일 1시 1분 일요일 인 날에 명령 실행
1 1 1 1 sun 명령어
#매시간 1분마다 명령어 실행
1 * * * * 명령어
#매 10분, 그러니까 10분, 20분, 30분~ 명령어 실행
*/10 * * * * 명령어
#매 3분, 그러니까 3분, 6분, 9분~ 명령어 실행
*/2 * * * * 명령어
# 9시부터 오후 10시까지 정각에 실행0 9-22 * * * 명령어#매시간 특정 분에 실행, 매시간 5분, 15분, 35분에 명령어 실행
5,15,35 * * * * 명령어
# 월요일~금요일 오전 9시 정각에 실행
0 9 * * 1-5 명령어
# 월요일~금요일 오전 9시 부터 21시까지 매시간 정각에 실행
0 9-21 * * 1-5 명령어
# 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
'Computer > Linux' 카테고리의 다른 글
워드프레스 설치하기 (0) | 2019.02.07 |
---|---|
라즈베리파이 조도센서 설치 BH1750 (디지털출력가능) (1) | 2019.02.07 |
라즈베리파이 i2c 활성화 (0) | 2019.02.07 |
라즈베리파이 온습도계 소스 (0) | 2019.02.07 |
VirtualHost 서브도메인 특정폴더로 연결 (0) | 2019.02.07 |
라즈베리파이 온도 습도 센서 DHT22 AM2302 연결 (0) | 2019.02.07 |
라즈베리 파이 웹서버 구성 APM 설치 + PhpMyAdmin + FTP (0) | 2019.02.07 |
라즈베리 파이 OS 설치 (NOOBS 기준으로 라즈비안 설치) (0) | 2019.02.07 |