summaryrefslogtreecommitdiff
path: root/src/journal/journal-vacuum.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-11-03 23:08:33 +0100
committerLennart Poettering <lennart@poettering.net>2014-11-03 23:08:33 +0100
commitdbd2a83fbf051fc51bdca3aa7536c78479488c5b (patch)
tree6514add1da5ccf64179b8094ed497fb5ee043115 /src/journal/journal-vacuum.c
parenta6e841b454e076ecbab6abc0bceb85ed06fd5c70 (diff)
journalctl: add new --vacuum-size= and --vacuum-time= commands to clean up journal files based on a size/time limit
This is equivalent to the effect of SystemMaxUse= and RetentionSec=, however can be invoked directly instead of implicitly.
Diffstat (limited to 'src/journal/journal-vacuum.c')
-rw-r--r--src/journal/journal-vacuum.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/journal/journal-vacuum.c b/src/journal/journal-vacuum.c
index 7699482a77..dbf5d2261b 100644
--- a/src/journal/journal-vacuum.c
+++ b/src/journal/journal-vacuum.c
@@ -143,7 +143,8 @@ int journal_directory_vacuum(
const char *directory,
uint64_t max_use,
usec_t max_retention_usec,
- usec_t *oldest_usec) {
+ usec_t *oldest_usec,
+ bool verbose) {
_cleanup_closedir_ DIR *d = NULL;
int r = 0;
@@ -152,6 +153,7 @@ int journal_directory_vacuum(
size_t n_allocated = 0;
uint64_t sum = 0, freed = 0;
usec_t retention_limit = 0;
+ char sbytes[FORMAT_BYTES_MAX];
assert(directory);
@@ -262,14 +264,12 @@ int journal_directory_vacuum(
uint64_t size = 512UL * (uint64_t) st.st_blocks;
if (unlinkat(dirfd(d), p, 0) >= 0) {
- log_info("Deleted empty journal %s/%s (%"PRIu64" bytes).",
- directory, p, size);
+ log_full(verbose ? LOG_INFO : LOG_DEBUG, "Deleted empty archived journal %s/%s (%s).", directory, p, format_bytes(sbytes, sizeof(sbytes), size));
freed += size;
} else if (errno != ENOENT)
- log_warning("Failed to delete %s/%s: %m", directory, p);
+ log_warning("Failed to delete empty archived journal %s/%s: %m", directory, p);
free(p);
-
continue;
}
@@ -297,8 +297,7 @@ int journal_directory_vacuum(
break;
if (unlinkat(dirfd(d), list[i].filename, 0) >= 0) {
- log_debug("Deleted archived journal %s/%s (%"PRIu64" bytes).",
- directory, list[i].filename, list[i].usage);
+ log_full(verbose ? LOG_INFO : LOG_DEBUG, "Deleted archived journal %s/%s (%s).", directory, list[i].filename, format_bytes(sbytes, sizeof(sbytes), list[i].usage));
freed += list[i].usage;
if (list[i].usage < sum)
@@ -307,7 +306,7 @@ int journal_directory_vacuum(
sum = 0;
} else if (errno != ENOENT)
- log_warning("Failed to delete %s/%s: %m", directory, list[i].filename);
+ log_warning("Failed to delete archived journal %s/%s: %m", directory, list[i].filename);
}
if (oldest_usec && i < n_list && (*oldest_usec == 0 || list[i].realtime < *oldest_usec))
@@ -318,7 +317,7 @@ finish:
free(list[i].filename);
free(list);
- log_debug("Vacuuming done, freed %"PRIu64" bytes", freed);
+ log_full(verbose ? LOG_INFO : LOG_DEBUG, "Vacuuming done, freed %s of archived journals on disk.", format_bytes(sbytes, sizeof(sbytes), freed));
return r;
}