[SOLVED] How to resolve /tmp Directory from filling up?

Hello Community,

I have OpenWRT 18.0.1 installed on a Linksys WRT 3200acm. I have been noticing some problems where some of my services/applications I installed on the router were starting to terminate on their own. Upon investigation, I have noticed that my memory was filling up via the Overview page on the Luci GUI. I then ssh into the router and checked its storage space by doing a df -h:

root@infraverse:/tmp# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                 8.8M      8.8M         0 100% /rom
tmpfs                   249.5M     224.6M    228.3M   91% /tmp
/dev/ubi0_1              51.4M      4.9M     43.8M  10% /overlay
overlayfs:/overlay       51.4M      4.9M     43.8M  10% /
ubi1:syscfg              70.2M    368.0K     66.2M   1% /tmp/syscfg
tmpfs                   512.0K         0    512.0K   0% /dev

The area I noticed that was filling up was this line:
tmpfs 249.5M 224.6M 228.3M 91% /tmp

Does anyone here know any troubleshooting methods to see what is taking up space in my /tmp directory?

Is there a script I can run that can be setup as a cron job once it hits a certain threshold?

I tried running these commands that usually works with other linux distros to clear out 10-day-old files in the tmp directory but it doesnt seem to work with OpenWRT.

find /tmp -type f -atime +10 -delete
find /tmp -ctime +10 -exec rm -rf {} +

Any help would greatly be appreciated and please let me know if you need any additional information.

reboot
# wait and do not remove anything
du /tmp | sort -n
2 Likes

Some of your installed services is probably configured to log too verbosely.
Or creates temp files without cleaning them after use.

Like vgaetera proposes, analyse tmp contents with du to identify possible culprits. Then you could disable the service that you believe is creating the files there, in order to check your hypothesis. And look for ways to decrease logging etc of that app.

1 Like

Thank you @vgaetera and @hnyman

That command worked great. I was able to find the application that was configured for debugging back when I was troubleshooting its install.

I was trying to figure out if it was possible to create a script to purge the folder of any directories/files that breach a size threshold, but I think it would be tricky as there are some system files in there that the software/system needs to operate and the other log files would be too specific to target.

I guess for now I will have to do it the manual way and keep an eye on it.

If your problem is solved, please consider marking this topic as [Solved]. (Click the pencil behind the topic...)

1 Like

Thank you @tmomas
I was just about to do that. Please feel free to update this with any cleaver scripts or commands that can purge files without having to reboot, it would be awesome :wink:

You can out-clever yourself by deleting large files in /tmp/, such as the image you're flashing. Since you know the name(s) of the file(s), I'd look into using logrotate (package) to mange them.

2 Likes

Thank you @jeff I will research that package!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.