I need to clean a file every x hours in order to clean RAM usage. With BusyBox v1.23.2
So I can do this:
cat /dev/null > myfile.txt
This works correctly. But, there are other processes that read this file and perform other actions, so how can I clean the file, and be sure that no other processes are reading/writing myfile.txt?
Pseudo code:
if(file_not_used()) ==> cat /dev/null > myfile.txt
I would like to do this with a bash script scheduled with crontabs.