crontab 적용이 안될 경우 질문드립니다..
안녕하세요 이제 막 리눅스를 만져보는 신입이 입니다.
다름이 아니라 cron을 이용한 주기적인 db 백업작업을 진행하려 하는데...인터넷에 나온대로 적용해서 하려하는데
cron이 작동하지 않습니다
crond를 사용하려 하는데
질문 1.
tact2@tact2:~/cron_backup$ sudo service crond restart
crond: unrecognized service
tact2@tact2:~/cron_backup$ ps -ef | grep crond
tact2 5876 5504 0 16:20 pts/5 00:00:00 grep --color=auto crond
위와 같은 경우 crond는 현재 실행 중인건가요..
질문 2.
#!bash/sh
sudo vi db_mysql_backup.sh 이렇게 파일을만들고
/usr/bin/mysqldump -uroot -proot --events --ignore-table=mysql.event --all-databases > /home/tact2/cron_backup/db_mysql_test$(date + %Y%m%d).sql
chomod +x db_mysql_backup.sh<<와 같이 권한부여하여 파일을 만들었는데 내용은 위와 같습니다.
커맨드창에서 위와 똑같이 명령어 실행하면 명령어 실행이 되는데 혹시 쉘 스크립트에 문제점이있나요..
질문 3.
crontab -l
# the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts at 5 a.m every week
# with: 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
*/1 * * * * /home/tact2/cron_backup/db_mysql_backup1.sh
위와 같은 경우 제가 제대로 cron에 등록한건지 정확히 모르겠습니다
여기까지는 crond로 한다면 생각해본것이고
=================================================================================================
바로 crontab 등록하여 사용하는 것도 해보았습니다
쉘 스크립트는 cron.hourly에 db_mysql_bak.sh로 지정해놓았고
crontab의 내용은 아래와 같습니다.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/etc/cron.hourly
#PATH=/usr/local/bin/:/sbin:/bin:/usr/sbin:/usr/bin
HOME=/
# 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 )
*/1 * * * * root run-parts /etc/cron.hourly
#
맨 밑줄이 추가내용입니다 왜 동작이 안되는지 선배님들의 관심어린 조언 부탁드립니다..감사합니다.
음 ..
service 가 crond 를 인식하지 못하고 crond 가 떠있지 않습니다.
/etc/init.d 에 crond 가 없다는 뜻인거 같고..
cron 이나 anacron 같은 다른 이름으로 되어 있을 수도 있습니다.
패키지가 설치되어 있는지 확인하시고, 정확한 서비스명을 찾아서 실행시켜 주세요.
되면 한다! / feel no sorrow, feel no pain, feel no hurt, there's nothing gained.. only love will then remain.. 『 Mizz 』
답변 감사드립니다
소중한 답변 감사드립니다.
현재까지는....
sudo service cron restart
cron stop/waiting
cron start/running, process 16031
tact2@tact2:/etc$
tact2@tact2:/etc$ ps -ef | grep cron
root 16031 1 0 13:22 ? 00:00:00 cron
tact2 16038 14765 0 13:23 pts/1 00:00:00 grep --color=auto cro
위와 같은 화면이 나온다면 cron이 실행 중인건가요..
현재 쉘 스크립트만 따로 실행해 본다면 실행이 되는데 왜 cron작업이 안되는건지 당췌 모르겠습니다...ㅠㅠ
도대체 얘가 왜이럴까요..
음 ..
일단 cron 은 떠 있는거 같네요.
cron 이 안 된다는게, cron 에서 그 시간에 스크립트를 실행한 로그가 없다는건가요..
아니면 cron 이 스크립트를 실행했는데 에러가 나서 실패했다는건가요..?
되면 한다! / feel no sorrow, feel no pain, feel no hurt, there's nothing gained.. only love will then remain.. 『 Mizz 』
이거슨...
혹시 몰라 crontab 내용도 올려봅니다 ..
SHELL=/bin/bash
#PATH=/usr/local/bin/:/sbin:/bin:/usr/sbin:/usr/bin
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/etc/cron.hourly;/
#HOME=/
# 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 )
*/1 * * * * tact2 run-parts /etc/cron.hourly/db_mysql_back.sh
...ㅠㅠ 감사합니다
cron녀석이...
cron녀석이 sh실행을 못하는거 같습니다
왜 안되는지 log를 보고싶은데 log쪽에 cron.log만 없습니다..
cron이 왜 안되는지 궁금해서 살것만 같습니다~~~ㅎㅎ
제가 이제 시작하여 잘몰라서 많이 부족하여 질문드립니다. crontab에 PATH는 어떤게 지정되는지 알 수 잇을까요..
쉘스크립트는 실행되는걸 확인했으니 아무리 생각해도 crontab의 문제인거같은데..ㅠㅠ
*/1 * * * * tact2 run-parts /etc/cron.hourly/db_mysql_back.sh<<<명령어를 rontab -e에 추가도해보고 crontab에도 넣어보고
그래두 안되네요...ㅠ.ㅠ 그리고 crontab에 추가하는것과 crontab -e로 추가하는건 다른점이 있나요....?
...ㅠㅠ
질문이 많아지네요 ...죄송합니다...
댓글 달기