8

在此处输入图像描述

我知道如果亚马逊用完一定数量的 CPU 时间,它会限制微型实例,但我认为情况并非如此。所有尖峰出现在世界标准时间 6:30 到 6:40 左右。我检查了我的 cron 作业,当时没有任何安排:

@reboot ~/path/to/script1.sh >> ~/log/cron.log
0 13 * * * ~/path/to/script2.sh >> ~/log/cron.log

还能是什么?

PS:注意 CPU Utilization 下拉菜单设置为“Maximum”。该图看起来与“平均”相似。PPS:此实例是 2 实例负载平衡设置的一部分。

这是我的 /etc/cron.daily 里面的内容(其他 crons 是空的):

apport、apt、aptitude、bsdmainutils、dpkg、logrotate、man-db、mlocate、passwd、流行度竞赛、标准、update-notifier-common

4

1 回答 1

10

通常,Amazon 上的 Ubuntu AMI 每天的 cron 作业都/etc/cron.daily安排在早上的时间。此计划使用 管理/etc/crontab。示例/etc/crontab如下所示:

$ cat /etc/crontab 
# /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 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6    * * 7   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6    1 * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#

显然,每日任务在早上 6:25 运行。如果这会影响服务器的直接交付,您可能需要调整这些设置以将日常任务移至其他时间。此外,您可以调查下的项目/etc/cron.daily。对我来说,它看起来像:

$ ls /etc/cron.daily/
apport  apt  aptitude  bsdmainutils  dpkg  logrotate  man-db  mlocate  popularity-contest  standard

其中,通常man-db并且logrotate可能会占用大量 CPU 时间来执行。这些是标准任务,可以进行调整以获得最佳性能。您可能需要考虑调整您的 logrotate 和 man-db 策略。

希望这可以帮助。

于 2012-12-21T05:25:21.207 回答