[Q] cron¿¡ ÀÇÇØ ÀÚµ¿À¸·Î ftp¸¦ ÇÏ¿© ÈÀÏÀ» ¼Û/¼ö½Å ÇÏ°Ô ÇÏ·Á¸é?
[A] 1. home directory¿¡ .netrc ÈÀÏÀ» ¸¸µé¾î ¾Æ·¡¿Í °°Àº ³»¿ëÀº Á¤ÀÇ ÇÑ´Ù.
% cd ~
% vi .netrc
machine ftp_server_hostname login ftp_username password ftp_user_passwd
¿¹) ftp_server_name : ftp.sun.com
ftp_username : anonymous
password : kim@sun.com
% vi .netrc
machine ftp.sun.com login anonymous password kim@sun.com
2. .netrc ÈÀÏÀÇ permissionÀº ¹Ýµå½Ã group¶Ç´Â other°¡ "read"ÇÒ¼ö ¾øµµ·Ï
ÇÑ´Ù.
% chmod 700 .netrc
3. À§¿Í °°ÀÌ Á¤ÀÇÇÑ ÈÄ ¾Æ·¡¿Í °°ÀÌ cron¿¡¼ ½ÇÇàÇÒ shell script¸¦ ¸¸µç´Ù.
% vi ftp_shell_script
ftp ftp.sun.com <<END
<ftp command>
.
.
.
quit
END
¿¹) % vi ftp_shell_script
ftp ftp.sun.com <<END
cd /pub
binary
get /usr/local/bin/trace trace
quit
END
4. ¸¸µç shell script°¡ ½ÇÇàµÉ¼ö ÀÖµµ·Ï permissionÀ» ¾Æ·¡¿Í °°ÀÌ º¯°æÇÑ´Ù.
% chmod 755 ftp_shell_script
5. crontab ¸í·ÉÀ» »ç¿ëÇÏ¿© cron¿¡ ÀÇÇØ ¼öÇàµÇµµ·Ï ¾Æ·¡¿Í °°ÀÌ Á¤ÀÇÇÑ´Ù.
% crontab -e
00 22 * * * ftp_shell_script >> /var/adm/ftpsession.log 2>&1
|