init: Make chromeos-cleanup-logs skip symlinks.
Make the chromeos-cleanup-logs script only delete regular
files when cleaning up directories.
I think that this solves the longstanding puzzle of why
powerd logs are sometimes missing from feedback reports: the
powerd.LATEST and powerd.PREVIOUS symlinks are only created
at boot, so if the directory gets big and the system has
been running for a while, the symlinks can get deleted.
BUG=chromium:743125
TEST=manual: verified that the current chromeos-cleanup-logs
deletes powerd.LATEST after i run e.g.
"touch -m -d 'last sunday' -h powerd.LATEST" to give it
an old mtime, but leaves it alone after making this
change
Change-Id: I44b5b17b8ed331e63f4498b28d76c5778c25f0c3
Reviewed-on: https://chromium-review.googlesource.com/572047
Commit-Ready: Dan Erat <derat@chromium.org>
Tested-by: Dan Erat <derat@chromium.org>
Reviewed-by: Benson Leung <bleung@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
(cherry picked from commit 2735652276307195f6320903b60c75a50cf8d2f4)
Reviewed-on: https://chromium-review.googlesource.com/574931
Reviewed-by: Dan Erat <derat@chromium.org>
diff --git a/init/chromeos-cleanup-logs b/init/chromeos-cleanup-logs
index dae743b..566437a 100755
--- a/init/chromeos-cleanup-logs
+++ b/init/chromeos-cleanup-logs
@@ -32,7 +32,7 @@
local file_pattern="$2"
local mtime=${NUM_DAYS_TO_PRESERVE}
while [ ${mtime} -ge 1 ]; do
- find "${subdir}" -name "${file_pattern}" -mtime "+${mtime}" -delete
+ find "${subdir}" -type f -name "${file_pattern}" -mtime "+${mtime}" -delete
if [ $(du -s --block-size=1M "${subdir}" | cut -f 1) -gt \
${MAX_SUBDIR_SIZE} ]; then
: $(( mtime -= 1 ))