linux下應用軟件突然丟失的的故障
問題描述:
某小系統早上發現應用軟件被刪除了,系統無法正常運行,相關人員均為找到原因.OS本版是RHEL6
1,登錄主機發現,/dev/sdb1同時掛載了兩個文件系統,注意/tmp也被mount
[plain]
[root@localhost ~]# df -h
文件系統 容量 已用 可用 已用%% 掛載點
/dev/mapper/VolGroup-lv_root
14G 6.8G 6.0G 54% /
tmpfs 4.0G 176K 4.0G 1% /dev/shm
/dev/sda1 485M 51M 409M 11% /boot
<span style="color:#FF0000">/dev/sdb1 40G 8.5G 29G 23% /spmwls
/dev/sdb1 40G 8.5G 29G 23% /tmp</span>
2,操作系統會每天刪除/tmp目錄下的文件,應該是默認刪除10天前的文件,所以/spmwls安裝的中間件軟件按被系統刪除了
[plain]
[root@localhost cron.daily]# pwd
/etc/cron.daily
[root@localhost cron.daily]# cat /etc/cron.daily/tmpwatch
#! /bin/sh
flags=-umc
/usr/sbin/tmpwatch "$flags" -x /tmp/.X11-unix -x /tmp/.XIM-unix \
-x /tmp/.font-unix -x /tmp/.ICE-unix -x /tmp/.Test-unix \
-X '/tmp/hsperfdata_*' 10d /tmp
/usr/sbin/tmpwatch "$flags" 30d /var/tmp
for d in /var/{cache/man,catman}/{cat?,X11R6/cat?,local/cat?}; do
if [ -d "$d" ]; then
/usr/sbin/tmpwatch "$flags" -f 30d "$d"
fi
done
3,再看cron的執行日志
[plain]
Oct 10 03:11:03 localhost run-parts(/etc/cron.daily)[62997]: starting tmpwatch
Oct 10 03:11:04 localhost run-parts(/etc/cron.daily)[63215]: finished tmpwatch
<strong>刪除部分文件失敗的日志
</strong>
/etc/cron.daily/tmpwatch:
error: failed to rmdir /tmp/weblogic1036/user_projects/domains/cmb/lib: Device or resource busy
4,備注: RHEL 6的cron的執行原理
RHEL6 中 cron daily的執行有了變化,通過man命令,可以得到cron執行的具體內容
a、/var/spool/cron目錄下的文件,這個目錄下和用crontab -l命令查看處理的相同
b、/etc/cron.d目錄下的文件
c、/etc/anacrontab文件中的內容,本次的tmpwatch就是通過這個文件執行的,這個文件會在3點鐘開始執行
[plain]
[root@localhost lib]# cat /etc/anacrontab
# /etc/anacrontab: configuration file for anacron
# See anacron(8) and anacrontab(5) for details.
SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# the maximal random delay added to the base delay of the jobs
RANDOM_DELAY=45
# the jobs will be started during the following hours only
START_HOURS_RANGE=3-22
#period in days delay in minutes job-identifier command
1 5 cron.daily nice run-parts /etc/cron.daily
7 25 cron.weekly nice run-parts /etc/cron.weekly
@monthly 45 cron.monthly nice run-parts /etc/cron.monthly
man cron
Cron searches /var/spool/cron for crontab files which are named after accounts in /etc/passwd; The founded crontabs are loaded into memory. Cron also
searches for /etc/anacrontab and the files in the /etc/cron.d directory,