
CentOS/RHEL 7/6/5에 Crontab을 설치하는 방법
우리 사이트 TecAdmin.net을 디지털 오션 호스팅의 새로운 VPS(CentOS 6.5)로 마이그레이션한 후 Crontab이 서버에 설치되지 않은 것을 발견했습니다. crontab -l 명령을 실행하려고 할 때 다음 오류를 발견했습니다. 파일에 저장됩니다.
# crontab -l -bash: crontab: command not found이전 시스템에서 crontab 명령 패키지를 확인한 후 cronie 패키지에서 가져온 것으로 나타났습니다. 그래서 TecAdmin.net 독자를 위해 작성하려고 생각합니다. 아래 명령어를 사용하여 설치합니다. 그러면 필요한 종속성도 설치됩니다.
크론탭 설치
# yum install cronie
Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.web-ster.com * updates: mirror.stanford.edu Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package cronie.x86_64 0:1.4.4-12.el6 will be installed --> Processing Dependency: dailyjobs for package: cronie-1.4.4-12.el6.x86_64 --> Running transaction check ---> Package cronie-anacron.x86_64 0:1.4.4-12.el6 will be installed --> Processing Dependency: crontabs for package: cronie-anacron-1.4.4-12.el6.x86_64 --> Running transaction check ---> Package crontabs.noarch 0:1.10-33.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: cronie x86_64 1.4.4-12.el6 base 73 k Installing for dependencies: cronie-anacron x86_64 1.4.4-12.el6 base 30 k crontabs noarch 1.10-33.el6 base 10 k Transaction Summary ========================================================== Install 3 Package(s) Total download size: 114 k Installed size: 220 k Is this ok [y/N]: y Downloading Packages: (1/3): cronie-1.4.4-12.el6.x86_64.rpm | 73 kB 00:00 (2/3): cronie-anacron-1.4.4-12.el6.x86_64.rpm | 30 kB 00:00 (3/3): crontabs-1.10-33.el6.noarch.rpm | 10 kB 00:00 -------------------------------------------------------------------------------- Total 336 kB/s | 114 kB 00:00 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : cronie-1.4.4-12.el6.x86_64 1/3 Installing : crontabs-1.10-33.el6.noarch 2/3 Installing : cronie-anacron-1.4.4-12.el6.x86_64 3/3 Verifying : crontabs-1.10-33.el6.noarch 1/3 Verifying : cronie-anacron-1.4.4-12.el6.x86_64 2/3 Verifying : cronie-1.4.4-12.el6.x86_64 3/3 Installed: cronie.x86_64 0:1.4.4-12.el6 Dependency Installed: cronie-anacron.x86_64 0:1.4.4-12.el6 crontabs.noarch 0:1.10-33.el6 Complete!
Crontab에서 새 작업을 추가하는 방법
새 cron을 추가하려면 crontab -e를 사용하여 편집기에서 편집하고 요구 사항에 따라 cron을 추가하십시오. 파일 시스템에서 cron은/var/spool/cron/# crontab -e아래 기사를 읽고 20가지 유용한 예제와 함께 Crontab에 대해 자세히 알아보세요. #!/crontab-in-linux-with-20-examples-of-cron-schedule/
Crontab에서 작업을 나열하는 방법
crontab에서 작업 스케줄러를 나열하려면 crontab 명령과 함께 -l 명령줄 스위치를 사용할 수 있습니다. 예를 들어 현재 사용자에게 예약된 작업을 나열하려면# crontab -l다른 사용자로 예약된 작업을 보려면 아래와 같이 -a 스위치를 사용하여 사용자 이름을 지정하십시오.
# crontab -u <username> -l