唉,我Ubuntu服务器上的updatedb.mlocate任务跑起来像老牛拉车,还没个头。
这个任务的优先级很低,因此机器性能倒是没有下降。但我坐在服务器旁边被迫听硬盘响个不停。好想能重新调度这个任务,让它在我不在时执行。我以为该任务由root帐户的cron文件启动,但我想错了。
在一番调查后,我发现:
* 该任务的参数列表在/etc/cron.daily/mlocate中。
#! /bin/sh
set -e
[ -x /usr/bin/updatedb.mlocate ] || exit 0
# See ionice(1)
if [ -x /usr/bin/ionice ]; then
IONICE=”/usr/bin/ionice -c3″
fi
$IONICE /usr/bin/updatedb.mlocate
* /etc/cron.daily下的文件由/etc/crontab文件启动,而非root的crontab命令。由于某些原因,Ubuntu的默认安装在每天6AM时运行该任务。改变该文件可以让我把运行时间调整到3AM。
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don’t have to run the `crontab’
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command
17 * * * * root cd / && run-parts –report /etc/cron.hourly
25 3 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts –report /etc/cron.daily )
47 3 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts –report /etc/cron.weekly )
52 3 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts –report /etc/cron.monthly )
#
* updatedb可以配置为忽略指定路径。由于我的机器有一些分区是用于备份的,我想把它们排除在updatedb任务之外。编辑/etc/updatedb.conf,增加路径到PRUNEPATHS路径可以实现这一目标。PRUNEPATHS选项中的路径将在updatedb执行时被排除在外。
PRUNE_BIND_MOUNTS=”yes”
PRUNEPATHS=”/tmp /var/spool /media /mnt/backup”
PRUNEFS=”NFS nfs nfs4 afs binfmt_misc proc smbfs autofs iso9660 ncpfs coda devpts ftpfs devfs mfs shfs sysfs cifs lustre_lite tmpfs usbfs udf rpc_pipefs”
阅读(2691) | 评论(0) | 转发(0) |