최근 일주일간 고민하던 내용이 있다. 1. root 계정으로 /test/test.sh 쉘스크립트를 짠다. test.sh의 대략적인 구조는 다음과 같다.
1 2 3 4 5 6 7 8 9 10 11 12 |
#!/bin/sh Today=$(echo `date +%Y%m%d`) testDir=$(echo /test/testDir/${Today}) mkdir ${testDir} cp -rp /var/log/httpd/error_log ${testDir} tar -cvzf ${testDir}/errorlog_${Today}.tar.gz /etc ncftpput -R -u copyuser -p password 192.168.1.1 /backup/testDirectory ${testDir}/*.* rm -rf ${testDir} cat /dev/null > /var/log/httpd/error_log exit 0 |
2. sh -x /test/test.sh 를 실행시 스크립트 내용이 잘 동작한다. 3. crontab -e 로 cron에 작업시간을 기재하여 매일 10시에…
최근 댓글