>  기사  >  운영 및 유지보수  >  Linux에서 crontab의 %의 특별한 의미가 무엇인지 아시나요?

Linux에서 crontab의 %의 특별한 의미가 무엇인지 아시나요?

藏色散人
藏色散人앞으로
2021-09-06 17:26:012079검색

다음 linux 시스템 튜토리얼 칼럼에서는 Linux에서 crontab의 % 사용법과 그 특별한 의미를 소개하겠습니다. 도움이 필요한 친구들에게 도움이 되길 바랍니다!

Linux에서 crontab의 %의 특별한 의미가 무엇인지 아시나요?

Linux에서 crontab 사용량의

crontab의 다음 스크립트는

 0 1 * * *   (cd /u01/prod; rsync -avz app 192.168.0.192:/u01/prod/) &>/home/applprod/backuplog/rsync_`date +%Y%m%d_%H%M%S`.log

실행할 수 없습니다. /var/log/messages 로그에 다음이 표시됩니다.

Sep 22 22:50:01 ebsapp CROND[13389]: (applprod) CMD ((cd /u01/prod; rsync -avz app 192.168.0.192:/u01/prod/) &>/home/applprod/backuplog/rsync_`date +)

명령이 다음과 같이 표시됩니다. 잘린 .

그래서 실행할 모든 명령을 스크립트로 캡슐화하고 이를 crontab에 넣어 실행했습니다.

그런데 나중에 crontab 맨페이지를 확인해보니 %가 crontab에서 특별한 의미를 갖고 있는 것을 발견했습니다.

The  "sixth"  field (the rest of the line) specifies the command to be run.  The entire command portion of the line, up to a new-
       line or % character, will be executed by /bin/sh or by the shell specified in the SHELL variable of the cronfile.   Percent-signs
       (%)  in  the  command, unless escaped with backslash (\), will be changed into newline characters, and all data after the first %
       will be sent to the command as standard input.

이제 문제는 crontab 명령이 잘린 것이 아니라 다른 의미를 갖고 있는 것으로 이해됩니다. 해결책 예, %를 탈출하면 수정된 스크립트는 다음과 같습니다:

03 23 * * * (cd /u01/prod; rsync -avz app 192.168.0.192:/u01/prod/) &>/home/applprod/backuplog/rsync_`date +\%Y\%m\%d_\%H\%M\%S`.log

위 내용은 Linux에서 crontab의 %의 특별한 의미가 무엇인지 아시나요?의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
이 기사는 segmentfault.com에서 복제됩니다. 침해가 있는 경우 admin@php.cn으로 문의하시기 바랍니다. 삭제