나는 다음과 같은 crontab
파일을 가지고 있습니다 -
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
* * * * * mango echo hi >> /home/mango/test
재시작 서비스를 사용했지만 sudo service cron restart
파일이 나타나지 않았습니다. 그래서 로그 파일을 확인하여 문제를 확인했습니다.
Sep 18 09:24:41 dpiplserver rsyslogd: [origin software="rsyslogd" swVersion="5.8.6" x-pid="869" x-info="http://www.rsyslog.com"] rsyslogd was HUPed
Sep 18 09:24:51 dpiplserver anacron[1157]: Job `cron.daily' terminated
Sep 18 09:24:51 dpiplserver anacron[1157]: Normal exit (1 job run)
Sep 18 09:39:01 dpiplserver CRON[2349]: (root) CMD ( [ -x /usr/lib/php5/maxlifetime ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1 -type f -cmin +$(/usr/lib/php5/maxlifetime) ! -execdir fuser -s {} 2>/dev/null \; -delete)
Sep 18 10:09:01 dpiplserver CRON[2399]: (root) CMD ( [ -x /usr/lib/php5/maxlifetime ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1 -type f -cmin +$(/usr/lib/php5/maxlifetime) ! -execdir fuser -s {} 2>/dev/null \; -delete)
Sep 18 10:16:08 dpiplserver kernel: [ 4726.374034] usb 2-1.5: new high-speed USB device number 3 using ehci_hcd
Sep 18 10:39:01 dpiplserver CRON[2803]: (root) CMD ( [ -x /usr/lib/php5/maxlifetime ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1 -type f -cmin +$(/usr/lib/php5/maxlifetime) ! -execdir fuser -s {} 2>/dev/null \; -delete)
Sep 18 10:50:21 dpiplserver kernel: [ 6773.998690] init: cron main process (1192) killed by TERM signal
Sep 18 10:50:21 dpiplserver cron[2880]: (CRON) INFO (pidfile fd = 3)
Sep 18 10:50:21 dpiplserver cron[2881]: (CRON) STARTUP (fork ok)
Sep 18 10:50:21 dpiplserver cron[2881]: (*system*) INSECURE MODE (group/other writable) (/etc/crontab)
Sep 18 10:50:21 dpiplserver cron[2881]: (CRON) INFO (Skipping @reboot jobs -- not system startup)
Sep 18 10:52:17 dpiplserver kernel: [ 6890.091067] init: cron main process (2881) killed by TERM signal
Sep 18 10:52:17 dpiplserver cron[2905]: (CRON) INFO (pidfile fd = 3)
Sep 18 10:52:17 dpiplserver cron[2906]: (CRON) STARTUP (fork ok)
Sep 18 10:52:17 dpiplserver cron[2906]: (*system*) INSECURE MODE (group/other writable) (/etc/crontab)
Sep 18 10:52:17 dpiplserver cron[2906]: (CRON) INFO (Skipping @reboot jobs -- not system startup)
Sep 18 10:54:41 dpiplserver kernel: [ 7033.797057] init: cron main process (2906) killed by TERM signal
Sep 18 10:54:41 dpiplserver cron[2937]: (CRON) INFO (pidfile fd = 3)
Sep 18 10:54:41 dpiplserver cron[2938]: (CRON) STARTUP (fork ok)
Sep 18 10:54:41 dpiplserver cron[2938]: (*system*) INSECURE MODE (group/other writable) (/etc/crontab)
Sep 18 10:54:41 dpiplserver cron[2938]: (CRON) INFO (Skipping @reboot jobs -- not system startup)
Sep 18 10:56:01 dpiplserver cron[2938]: (*system*) INSECURE MODE (group/other writable) (/etc/crontab)
Sep 18 10:56:57 dpiplserver kernel: [ 7168.922614] init: cron main process (2938) killed by TERM signal
Sep 18 10:56:57 dpiplserver cron[2953]: (CRON) INFO (pidfile fd = 3)
Sep 18 10:56:57 dpiplserver cron[2954]: (CRON) STARTUP (fork ok)
Sep 18 10:56:57 dpiplserver cron[2954]: (*system*) INSECURE MODE (group/other writable) (/etc/crontab)
Sep 18 10:56:57 dpiplserver cron[2954]: (CRON) INFO (Skipping @reboot jobs -- not system startup)
Sep 18 10:59:34 dpiplserver kernel: [ 7325.393315] init: cron main process (2954) killed by TERM signal
Sep 18 10:59:34 dpiplserver cron[2967]: (CRON) INFO (pidfile fd = 3)
Sep 18 10:59:34 dpiplserver cron[2968]: (CRON) STARTUP (fork ok)
Sep 18 10:59:34 dpiplserver cron[2968]: (*system*) INSECURE MODE (group/other writable) (/etc/crontab)
Sep 18 10:59:34 dpiplserver cron[2968]: (CRON) INFO (Skipping @reboot jobs -- not system startup)
Sep 18 11:00:21 dpiplserver kernel: [ 7372.324581] init: cron main process (2968) killed by TERM signal
Sep 18 11:00:21 dpiplserver cron[2977]: (CRON) INFO (pidfile fd = 3)
Sep 18 11:00:21 dpiplserver cron[2978]: (CRON) STARTUP (fork ok)
Sep 18 11:00:21 dpiplserver cron[2978]: (*system*) INSECURE MODE (group/other writable) (/etc/crontab)
Sep 18 11:00:21 dpiplserver cron[2978]: (CRON) INFO (Skipping @reboot jobs -- not system startup)
Sep 18 11:09:01 dpiplserver CRON[3060]: (root) CMD ( [ -x /usr/lib/php5/maxlifetime ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1 -type f -cmin +$(/usr/lib/php5/maxlifetime) ! -execdir fuser -s {} 2>/dev/null \; -delete)
Sep 18 11:09:18 dpiplserver crontab[3068]: (mango) LIST (mango)
Sep 18 11:09:50 dpiplserver crontab[3089]: (root) LIST (root)
Sep 18 11:13:34 dpiplserver kernel: [ 8163.398965] init: cron main process (2978) killed by TERM signal
Sep 18 11:13:34 dpiplserver cron[3144]: (CRON) INFO (pidfile fd = 3)
Sep 18 11:13:34 dpiplserver cron[3145]: (CRON) STARTUP (fork ok)
Sep 18 11:13:34 dpiplserver cron[3145]: (*system*) INSECURE MODE (group/other writable) (/etc/crontab)
Sep 18 11:13:34 dpiplserver cron[3145]: (CRON) INFO (Skipping @reboot jobs -- not system startup)
Sep 18 11:15:22 dpiplserver kernel: [ 8271.390434] init: cron main process (3145) killed by TERM signal
Sep 18 11:15:22 dpiplserver cron[3163]: (CRON) INFO (pidfile fd = 3)
Sep 18 11:15:22 dpiplserver cron[3164]: (CRON) STARTUP (fork ok)
Sep 18 11:15:22 dpiplserver cron[3164]: (*system*) INSECURE MODE (group/other writable) (/etc/crontab)
Sep 18 11:15:22 dpiplserver cron[3164]: (CRON) INFO (Skipping @reboot jobs -- not system startup)
로그 파일에는 실행한 명령이나 발생한 오류가 표시될 것으로 예상했습니다. 왜 성공이나 오류가 인쇄되지 않습니까?
답변1
파일에 /etc/crontab
잘못된 권한이 있으므로 cron
파일이 무시되고 파일 내의 작업이 실행되지 않습니다.
9월 18일 11:15:22 dpiplserver cron[3164]: (체계) 안전하지 않은 모드(그룹/기타 쓰기 가능) (/etc/crontab)
명령을 사용하여 수정
sudo chmod 600 /etc/crontab
그리고 서비스를 다시 시작하세요
sudo service cron restart