2022. 7. 13. 10:11ใTIL/Linux
โ๏ธ ๋ฌธ์
crontab ์ค์ ์ดํ ๋ฉ๋ชจ๋ฆฌ ์ฌ์ฉ๋ฅ , Disk I/O, Disk ์ฌ์ฉ๋ฅ ์ด ์๋์ ๊ฐ์ด ์ง์์ ์ผ๋ก ์ฆ๊ฐํ์๋ค.
๐ ํ๊ฒฝ
- AWS EC2
- OS: Amazon Linux
๐ ๋ฌธ์ ๋ฅผ ํ์ ํด๋ณด์.
1. ๊ฐ ํ๋ก์ธ์ค์ ๋ฉ๋ชจ๋ฆฌ ์ฌ์ฉ๋ฅ ํ์ธ
top > shift + m
(ps -ef —sort -rss๋ก๋ ํ์ธ ๊ฐ๋ฅ)
memory ์ฌ์ฉ๋ฅ ์ ๋ด๋ฆผ์ฐจ์์ผ๋ก ์ ๋ ฌํ์ฌ ํ๋ก์ธ์ค๋ฅผ ํ์ธํ ์ ์๋ค.
๋ฉ๋ชจ๋ฆฌ๋ฅผ ๋๊ฒ ์ฌ์ฉํ๋ ์์ ํ๋ก์ธ์ค์ ์ฌ์ฉ๋ฅ ์ ๊ธฐ์กด์ ์๋น์ค๋๊ณ ์๋ ํ๋ก์ธ์ค์์ผ๋ฉฐ, ๋ฉ๋ชจ๋ฆฌ ์ฌ์ฉ๋ฅ ๋ ํ์์ฒ๋ผ ์ ์์ ์ด์๋ค.
๋ค๋ง, ์์ ๊ฐ์ด ํน์ ๊ณ์ ์์ sendmail๊ณผ postdrop์ด ๋น์ ์์ ์ผ๋ก ๋ง์ด ์คํ๋๊ณ ์์๋ค.
ps -ef | grep sendmail
ps -ef | grep postdrop
2. /var/log์์ ๊ด๋ จ ๋ก๊ทธ ํ์ธ
2-1. ๋ก๊ทธ ํ์ผ ํฌ๊ธฐ ํ์ธ
cd /var/log
ll | grep messages
ll | grep maillog
/var/log/messages ํ์ผ๊ณผ /var/log/maillog ํ์ผ๊ณผ ๋ฌธ์ ๋ฐ์ ํ ์์ฑ๋ messages ํ์ผ(ex: /var/log/messages-20220710) ๋ฐ maillog ํ์ผ(ex: /var/log/maillog-20220710)์ ํฌ๊ธฐ๊ฐ ๊ธฐ์กด๊ณผ ๋ค๋ฅด๊ฒ ๋น์ ์์ ์ผ๋ก ํฌ๋ค.
2-2. ๋ก๊ทธ ํ์ผ ๋ด์ฉ ํ์ธ
cat /var/log/messages | tail -50
cat /var/log/maillog | tail -50
crond: postdrop: warning: mail_queue_enter: create file maildrop/xxxxxx.xxxxx: Permission denied
postfix/postdrop[xxxx]: warning: mail_queue_enter: create file maildrop/xxxxxx.xxxx: Permission denied
/var/log/messages์ /var/log/maillog์ postdrop์ permission ๊ด๋ จ ๋ฉ์์ง๊ฐ ๊ณผ๋ํ๊ฒ ๊ธฐ๋ก๋๊ณ ์์๋ค.
crontab ์ค์ ์ดํ ๋ฉ์ผ ๋ฐ์ก์์ ๋ฐ์ํ ๊ถํ ๊ด๋ จ ๋ฌธ์ ๋ก ์ถ์ ํ ์ ์๋ค.
⇒ ๋ฉ๋ชจ๋ฆฌ ์ฌ์ฉ๋ฅ ์ด ๋์์ง ์์ธ : sendmail, postdrop ํ๋ก์ธ์ค ๊ณผ๋ค ์คํ
⇒ Disk I/O ๋ฐ Disk ์ฌ์ฉ๋์ด ๋์์ง ์์ธ : postdrop ๊ด๋ จ ๋ก๊น
๐ซ Trouble Shooting
1. ๊ถํ ๋ณ๊ฒฝ
# postfix์ ์ต์ด ์์ ๊ถ์ผ๋ก ๋ณ๊ฒฝ
rpm --setugids postfix
# postfix์ ์ต์ด ํผ๋ฏธ์
์ผ๋ก ๋ณ๊ฒฝ
rpm --setperms postfix
# postfix ์๋น์ค ์ฌ์์
systemctl restart postifx
2. postdrop ํ๋ก์ธ์ค kill
killall postdrop
3. error message ์ญ์
vim /var/log/messages #dG ์
๋ ฅํ์ฌ ๋ด์ฉ ์ญ์
vim /var/log/maillog #dG ์
๋ ฅํ์ฌ ๋ด์ฉ ์ญ์
# rsyslog.service ์ฌ์์
systemctl restart rsyslog.service
systemctl status rsyslog.service
์ถ๊ฐ๋ก, /var/log/messages-{๋ ์ง}, /var/log/maillog-{๋ ์ง} ํ์ผ์ ํฌ๊ธฐ๊ฐ ๋น์ ์์ ์ผ๋ก ํฐ ๊ฒฝ์ฐ ํด๋น ํ์ผ๋ ์ญ์ ํ๋ค.
rm -rf /var/log/messages-{๋ ์ง}
rm -rf /var/log/maillog-{๋ ์ง}
4. (์ ํ) ๋ชจ๋ crond ์์ ์ ๋ํด ๋ฉ์ผ ๋ฐ์ก ๋นํ์ฑํ
vi /etc/crontab
MAILTO="" # MAILTO=root(default๊ฐ)๋ฅผ ๋น ๋ฌธ์์ด๋ก ๋ณ๊ฒฝ
vi /etc/sysconfig/crond
CRONDARGS="-m off"
# crond ์ฌ์์
systemctl restart crond
systemctl status crond
crontab์ ์์ฝ๋ ์์ ์ ์คํ ํ์ ๊ฒฐ๊ณผ์ ๋ํด mail์ ๋ฐ์กํ๋ค.
- MAILTO ํ๊ฒฝ ๋ณ์๊ฐ ์๋ ๊ฒฝ์ฐ : cron ์์ ์ ์์ ์์๊ฒ ๋ฉ์ผ ์ ์ก.
- MAILTO=root : root์๊ฒ ๋ฉ์ผ ์ ์ก. (์ง์ ํ ์ด๋ฉ์ผ ์ฃผ์์ ๋ฉ์ผ ์ ์ก)
- MAILTO=”” : ๋ฉ์ผ ์ ์กํ์ง ์์.
๐ก SendMail & Postfix
์ฐธ๊ณ ์ฌ์ดํธ: Is Postfix the same thing as Sendmail?
- ๋ชจ๋ mail transfer agent.
- Sendmail is a different (and much older) program from Postfix. However for every mail server to succeed in the Unix environment, a sendmail binary (with some of the expected command line options) must be provided.
- Architecture: The most common difference between these two is architecture. Postfix has a modular architecture composed of many independent small executables. It provides multiple options, parameters, and features. In contrast, Sendmail has a monolithic design that uses a single process always running at the backend.
- postdrop์ postfix์ mail posting utility์ด๋ค.
๐ ์ฐธ๊ณ ๋งํฌ
- ๊ธฐ์ ๋ธ๋ก๊ทธ: Postfix vs. Sendmail
- ๊ธฐ์ ๋ธ๋ก๊ทธ: [EC2] /var/log/messages์ /var/log/maillog์ postdrop ์๋ฌ๋ฉ์ธ์ง๊ฐ ๋๋์ผ๋ก ๋ฐ์์ด ๋ฉ๋๋ค.
- ๊ธฐ์ ๋ธ๋ก๊ทธ: crond, crontab ์คํ ํ mail ๋ฐ์ก ์ค์ ๊ธ์ง
- ๊ธฐ์ ๋ฌธ์: cron ์์ ์ด ์คํจํ์๋๋ง ์ด๋ฉ์ผ ์ ์กํ๊ธฐ
- ๊ธฐ์ ์ฌ์ดํธ: Is Postfix the same thing as Sendmail?
- Linux ๋ฌธ์: postdrop(1) - Linux man page