Delete ts-tmp files to free up storage
Note: This page applies to SFTP Gateway version 2.x. Visit Here for documentation on version 3.x.
Overview
In SFTP Gateway version 2.001.x, task spooler log files are stored in the folder:
/ts-tmp
Over time, these log files can accumulate and use up a significant amount of disk storage.
This article shows you how to use systemd
to automatically clean out
the /ts-tmp
folder.
Background
In SFTP Gateway version 2.001.x, various tasks (sync operations, move to cloud commands, etc) are queued to the task spooler.
The task spooler logs send output to the /ts-tmp
folder.
While this output can be silenced using the ts -n
parameter,
this is not always possible, because you would also lose the ability
to reference that task via the task ID.
As a result, the /ts-tmp
folder will continuously grow in size.
Given enough time, you will eventually run out of disk storage.
Deleting log files manually
If your server is out of space, you can clean out this folder immediately.
find /ts-tmp -type f -mtime +1 -exec rm -f {} \;
This command looks for any files in /ts-tmp
that are older than a day,
and then deletes them.
Note: Although it may be tempting to delete the entire /ts-tmp
folder, this could interfere with processes currently in the task spooler.
Deleting log files with systemd
Logrotate is normally used to keep log file size in check. But task spooler doesn't log to a single file -- rather, there is a separate log file for each task. So, the tool of choice for this situation is systemd.
To configure this, create the file:
/etc/tmpfiles.d/ts-tmp.conf
And paste the following contents:
D /ts-tmp 0755 root root 1d
And you're done.
From now on, systemd will automatically delete any files in the
/ts-tmp
folder that is older than a day.
Explanation of how it works
Systemd runs a daily job that cleans out temp files. You can check when this job is run, using the command:
systemctl list-timers
You can get a sense of what the command will do, by running it manually:
env SYSTEMD_LOG_LEVEL=debug systemd-tmpfiles --clean
This command will look for any configuration files within:
/etc/tmpfiles.d/
This is the syntax you are using:
D /ts-tmp 0755 root root 1d
D
: This cleans an existing directory, or creates it if it doesn't exist./ts-tmp
: This is the directory.0755 root root
: This is the mode and ownership used when creating the directory.1d
: Any files in this directory older than 1 day are cleaned out.
Note: The D
syntax is used, because it is triggered by the --clean
parameter of systemd-tmpfiles
.