2014年8月11日月曜日

yumでpostfix削除したらcronが動かなくなってはまった件

postfix入れなくていいサーバーだったので、
yumでpostfixを削除したらcronが動かなくなりはまってしまいました。

yum removeで削除したところ。
何も確認しないで削除してたら、依存してるものもいくつか消していました。
その中にcrontabsもいました。
# yum remove postfix
Loaded plugins: fastestmirror, security
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package postfix.x86_64 2:2.6.6-2.2.el6_1 will be erased
--> Processing Dependency: /usr/sbin/sendmail for package: cronie-1.4.4-12.el6.x86_64
--> Running transaction check
---> Package cronie.x86_64 0:1.4.4-12.el6 will be erased
--> Processing Dependency: cronie = 1.4.4-12.el6 for package: cronie-anacron-1.4.4-12.el6.x86_64
--> Running transaction check
---> Package cronie-anacron.x86_64 0:1.4.4-12.el6 will be erased
--> Processing Dependency: /etc/cron.d for package: crontabs-1.10-33.el6.noarch
--> Processing Dependency: /etc/cron.d for package: sysstat-9.0.4-22.el6.x86_64
--> Restarting Dependency Resolution with new changes.
--> Running transaction check
---> Package crontabs.noarch 0:1.10-33.el6 will be erased
---> Package sysstat.x86_64 0:9.0.4-22.el6 will be erased
--> Finished Dependency Resolution
base                                                                                                                                  | 3.7 kB     00:00     
epel/metalink                                                                                                                         | 4.2 kB     00:00     
epel                                                                                                                                  | 4.4 kB     00:00     
epel/primary_db                                                                                                                       | 6.3 MB     00:00     
extras                                                                                                                                | 3.4 kB     00:00     
updates                                                                                                                               | 3.4 kB     00:00     
 
Dependencies Resolved
 
=============================================================================================================================================================
 Package                         Arch                    Version                             Repository                                                 Size
=============================================================================================================================================================
Removing:
 postfix                         x86_64                  2:2.6.6-2.2.el6_1                   @anaconda-CentOS-201311291202.x86_64/6.5                  9.7 M
Removing for dependencies:
 cronie                          x86_64                  1.4.4-12.el6                        @anaconda-CentOS-201311291202.x86_64/6.5                  174 k
 cronie-anacron                  x86_64                  1.4.4-12.el6                        @anaconda-CentOS-201311291202.x86_64/6.5                   43 k
 crontabs                        noarch                  1.10-33.el6                         @anaconda-CentOS-201311291202.x86_64/6.5                  2.4 k
 sysstat                         x86_64                  9.0.4-22.el6                        @anaconda-CentOS-201311291202.x86_64/6.5                  824 k
 
Transaction Summary
=============================================================================================================================================================
Remove        5 Package(s)
 
Installed size: 11 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Erasing    : sysstat-9.0.4-22.el6.x86_64                                                                                                               1/5 
  Erasing    : cronie-anacron-1.4.4-12.el6.x86_64                                                                                                        2/5 
  Erasing    : crontabs-1.10-33.el6.noarch                                                                                                               3/5 
  Erasing    : cronie-1.4.4-12.el6.x86_64                                                                                                                4/5 
  Erasing    : 2:postfix-2.6.6-2.2.el6_1.x86_64                                                                                                          5/5 
警告: /etc/postfix/main.cf は /etc/postfix/main.cf.rpmsave として保存されました。
  Verifying  : crontabs-1.10-33.el6.noarch                                                                                                               1/5 
  Verifying  : cronie-anacron-1.4.4-12.el6.x86_64                                                                                                        2/5 
  Verifying  : sysstat-9.0.4-22.el6.x86_64                                                                                                               3/5 
  Verifying  : 2:postfix-2.6.6-2.2.el6_1.x86_64                                                                                                          4/5 
  Verifying  : cronie-1.4.4-12.el6.x86_64                                                                                                                5/5 
 
Removed:
  postfix.x86_64 2:2.6.6-2.2.el6_1                                                                                                                           
 
Dependency Removed:
  cronie.x86_64 0:1.4.4-12.el6        cronie-anacron.x86_64 0:1.4.4-12.el6        crontabs.noarch 0:1.10-33.el6        sysstat.x86_64 0:9.0.4-22.el6       
 
Complete!

cronがいるはずのディレクトリを探してもいません。。。
# ls /etc/init.d/c*
/etc/init.d/certmonger  /etc/init.d/cpuspeed
 
# ls /usr/bin/cr*
/usr/bin/crash  /usr/bin/crlutil


yumでcrontabを入れます。
# yum install crontabs
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
 * base: www.ftp.ne.jp
 * epel: ftp.kddilabs.jp
 * extras: www.ftp.ne.jp
 * updates: www.ftp.ne.jp
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package crontabs.noarch 0:1.10-33.el6 will be installed
--> Processing Dependency: /etc/cron.d for package: crontabs-1.10-33.el6.noarch
--> Running transaction check
---> Package cronie.x86_64 0:1.4.4-12.el6 will be installed
--> Processing Dependency: dailyjobs for package: cronie-1.4.4-12.el6.x86_64
--> Processing Dependency: /usr/sbin/sendmail for package: cronie-1.4.4-12.el6.x86_64
--> Running transaction check
---> Package cronie-anacron.x86_64 0:1.4.4-12.el6 will be installed
---> Package exim.x86_64 0:4.72-5.el6 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
=============================================================================================================================================================
 Package                                   Arch                              Version                                   Repository                       Size
=============================================================================================================================================================
Installing:
 crontabs                                  noarch                            1.10-33.el6                               base                             10 k
Installing for dependencies:
 cronie                                    x86_64                            1.4.4-12.el6                              base                             73 k
 cronie-anacron                            x86_64                            1.4.4-12.el6                              base                             30 k
 exim                                      x86_64                            4.72-5.el6                                epel                            1.2 M
 
Transaction Summary
=============================================================================================================================================================
Install       4 Package(s)
 
Total download size: 1.3 M
Installed size: 4.0 M
Is this ok [y/N]: y
Downloading Packages:
(1/4): cronie-1.4.4-12.el6.x86_64.rpm                                                                                                 |  73 kB     00:00     
(2/4): cronie-anacron-1.4.4-12.el6.x86_64.rpm                                                                                         |  30 kB     00:00     
(3/4): crontabs-1.10-33.el6.noarch.rpm                                                                                                |  10 kB     00:00     
(4/4): exim-4.72-5.el6.x86_64.rpm                                                                                                     | 1.2 MB     00:00     
-------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                        4.1 MB/s | 1.3 MB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : exim-4.72-5.el6.x86_64                                                                                                                    1/4 
  Installing : cronie-1.4.4-12.el6.x86_64                                                                                                                2/4 
  Installing : crontabs-1.10-33.el6.noarch                                                                                                               3/4 
  Installing : cronie-anacron-1.4.4-12.el6.x86_64                                                                                                        4/4 
  Verifying  : crontabs-1.10-33.el6.noarch                                                                                                               1/4 
  Verifying  : cronie-anacron-1.4.4-12.el6.x86_64                                                                                                        2/4 
  Verifying  : exim-4.72-5.el6.x86_64                                                                                                                    3/4 
  Verifying  : cronie-1.4.4-12.el6.x86_64                                                                                                                4/4 
 
Installed:
  crontabs.noarch 0:1.10-33.el6                                                                                                                              
 
Dependency Installed:
  cronie.x86_64 0:1.4.4-12.el6                      cronie-anacron.x86_64 0:1.4.4-12.el6                      exim.x86_64 0:4.72-5.el6                     
 
Complete!

無事に入りました。
cronがいるべきディレクトリを見てみると、
ちゃんとcrondとcrontabが存在してました。
よかった。
# ls /etc/init.d/c*
/etc/init.d/certmonger  /etc/init.d/cpuspeed  /etc/init.d/crond
 
# ls /usr/bin/cr*
/usr/bin/crash  /usr/bin/crlutil  /usr/bin/crontab

yumで削除する時は一緒に消されるものもちゃんと確認しようと心に誓いました。

2014年8月5日火曜日

linuxのmailコマンドでメールが送れなかったので調べた件

Linuxからmailコマンドでメールを送ろうとしたけど送れなかったので、
その時にいろいろ調べた件を書きます。

環境
CentOS6.5

まずは普通にmailコマンドでメールを送信してみた。
# mail ユーザー名@ドメイン
Subject: test
send test
.
EOT
could not connect: 接続がタイムアウトしました
"/root/dead.letter" 11/341
. . . message not sent.
タイムアウトになって送れませんでした。
このとき、/var/log/maillogにも何も吐かれてませんでした。

次に-vのオプションをつけて再度実行してみました。
# mail -v ユーザー名@ドメイン
Subject: test
send test
.
EOT
Resolving host 10.24.100.12 . . . done.
Connecting to 10.24.100.12 . . .could not connect: 接続がタイムアウトしました
"/root/dead.letter" 11/341
. . . message not sent.
またもタイムアウトになって送れませんでしたが、
どのhostに繋がらないのかがわかりました。

この繋がらない10.24.100.12がどこの設定に書かれているのかを調べたところ、
ここの設定ファイルに書かれていました。
# cat /etc/mail.rc
# This is the configuration file for Heirloom mailx (formerly
# known under the name "nail".
# See mailx(1) for further options.
# This file is not overwritten when 'make install' is run in
# the mailx build process again.
 
# Sccsid @(#)nail.rc 2.10 (gritter) 3/4/06
 
# Do not forward to mbox by default since this is likely to be
# irritating for most users today.
set hold
 
# Append rather than prepend when writing to mbox automatically.
# This has no effect unless 'hold' is unset again.
set append
 
# Ask for a message subject.
set ask
 
# Assume a CRT-like terminal and invoke a pager.
set crt
 
# Messages may be terminated by a dot.
set dot
 
# Do not remove empty mail folders in the spool directory.
# This may be relevant for privacy since other users could
# otherwise create them with different permissions.
set keep
 
# Do not remove empty private mail folders.
set emptybox
 
# Quote the original message in replies by "> " as usual on the Internet.
set indentprefix="> "
 
# Automatically quote the text of the message that is responded to.
set quote
 
# Outgoing messages are sent in ISO-8859-1 if all their characters are
# representable in it, otherwise in UTF-8.
set sendcharsets=iso-8859-1,utf-8
 
# Display sender's real names in header summaries.
set showname
 
# Display the recipients of messages sent by the user himself in
# header summaries.
set showto
 
# Automatically check for new messages at each prompt, but avoid polling
# of IMAP servers or maildir folders.
set newmail=nopoll
 
# If threaded mode is activated, automatically collapse thread.
set autocollapse
 
# Hide some header fields which are uninteresting for most human readers.
ignore received in-reply-to message-id references
ignore mime-version content-transfer-encoding
 
# Only include selected header fields when forwarding messages.
fwdretain subject date from to
 
# For Linux and BSD, this should be set.
set bsdcompat
 
set smtp=10.24.100.12
set smtpのIPを繋がるものに変更したところ、正常にmailコマンドでメールが送れるようになりました。