yumyum
[Linux] CRON과 AT 본문
[cron]
- 주기적으로 반복되는 일을 자동적으로 실행될 수 있도록 설정
- 관련된 데몬(서비스)은 "crond", 관련 파일은 " /etc/crontab"
(ex) /etc/crontab
- 01 * * * * root run-parts /etc/cron.hourly
- 02 4 * * * root run-parts /etc/cron.daily
- 03 4 * * o root run-parts /etc/cron.weekly
- 42 4 1 * * root run-parts /etc/cron.monthly
- 첫 줄은 매시간 1분에 /etc/cron.hourly 디렉터리 안에 있는 명령들을 자동으로 실행한다
[root@localhost mnt]# vim /etc/crontab
[root@localhost mnt]# crontab -e
no crontab for root - using an empty one
crontab: installing new crontab
[root@localhost mnt]# crontab -l
40 * * * * cat /var/log/messages > /backup/log.bak
[root@localhost mnt]#
[root@localhost mnt]#
[root@localhost mnt]# systemctl restart crond
[root@localhost mnt]#
[AT]
- cron은 주기적으로 반복되는 작업을 예약하는 것이지만, at는 일회성 작업을 예약
(ex)
- 예약 : # at <시간>
=> # at 3:00am tomorrow -> 내일 새벽 3시
# at 11:00pm January 30 -> 1월 30일 오후 11시
# at now + 1 hours -> 1시간 후
- at> 프롬프트에 예약 명령어 입력 후 [Enter]
- 완료되면 [Ctrl] + [D]
- 확인 : #at -1
- 취소 : # atrm <작업번호>
[root@localhost backup]# at 12: 12 pm
syntax error. Last token seen: :
Garbled time
[root@localhost backup]# su -
마지막 로그인: 목 8월 31 10:42:50 KST 2023 일시 pts/0
[root@localhost ~]# at 12:12 pm
at> yum -y update
at> reboot
at> <EOT>
job 1 at Thu Aug 31 12:12:00 2023
[root@localhost ~]#
[root@localhost ~]# at -l
1 Thu Aug 31 12:12:00 2023 a root
[root@localhost ~]# ps -ef | grep yum
root 5382 5381 18 12:11 ? 00:00:00 /usr/bin/python /bin/yum -y update
root 5389 5317 0 12:12 pts/0 00:00:00 grep --color=auto yum
[root@localhost ~]#
Every 20.0s: ps -ef | grep yum Thu Aug 31 12:13:26 2023
root 5382 5381 37 12:11 ? 00:00:32 /usr/bin/python /bin/yum -y update
root 15274 5317 0 12:13 pts/0 00:00:00 watch -n 20 ps -ef | grep yum
root 15275 15274 0 12:13 pts/0 00:00:00 watch -n 20 ps -ef | grep yum
root 15276 15275 0 12:13 pts/0 00:00:00 sh -c ps -ef | grep yum
root 15278 15276 0 12:13 pts/0 00:00:00 sh -c ps -ef | grep yum
'ICT기반 클라우드 네트워크 해킹 침해대응전문가 > Linux' 카테고리의 다른 글
[Linux] 디스크 파티션, fstab (0) | 2023.09.01 |
---|---|
[Linux] 파이프, 필터, 리다이렉션, 프로세스, 데몬 (0) | 2023.08.31 |
[Linux] 파일 압축, 파일 묶기 (0) | 2023.08.31 |
[Linux] RPM, dnf (1) | 2023.08.30 |
[Linux] hardlink, softlink (0) | 2023.08.30 |