1 Rookie
•
5 Posts
0
29
September 19th, 2025 13:54
OneFS 9.7.1 auto-deleting files after 7 days - seemingly simple, and yet not entirely so.
Hi there,
I'm trying to find a way to set auto-deleting files older than 7 days, from one specified path.
I tried two methods:
1. Adding a policy that would do this.
I tried the following commands using CLI:
isi filepolicy rules create my_delete_rule \
--path=/ifs/XYZ \
--file-older-than=7d \
--action=delete
and second attempt:
isi filepool policies create xyz_test \ --path=/ifs/XYZ \ --file-older-than=7d \ --action=delete
Both attempts ended in failure.
2. Script:
FOLDER="/ifs/XYZ/test-folder/"
LOG="/ifs/ZZZ/delete_log_$(date +%F).log"
# Delete files older than 7 days and write logfind
"$FOLDER" -type f -print -mtime +7 -delete >> "$LOG" 2>&1
Please, could someone advise me on how to effectively set up automatic deletion of files from a given folder after 7 days?
Skymaster64
1 Rookie
•
1 Message
0
September 26th, 2025 06:13
Script snippets that work for us:
#cleans all empty folders
find /ifs/XYZ/* -depth -type d -empty -exec rm -d {} \;
#Deletes all files created more than 7 days ago.
find /ifs/XYZ/* -depth -type f -ctime +7d -exec rm -d {} \;
M52B28
1 Rookie
•
5 Posts
0
September 26th, 2025 11:33
@M52B28 I founded a bugs. Below correct row from crontab, it works:
39 12 * * * /usr/bin/bash /ifs/scripts/delete_old_files.sh >> /ifs/logs/myscript.log 2>&1
storageSysAdmin
1 Rookie
•
56 Posts
0
September 19th, 2025 15:00
I dont think thats a valid option to purge data after so many days, its the one thins OneFS is bad at is proper lifecycle management tooling.
You would have to have a script do it for you, but just make sure its not misused in anyway!
M52B28
1 Rookie
•
5 Posts
0
September 22nd, 2025 09:48
There is a certain XYZ folder that is used solely for the exchange of data between users. Data stored in the XYZ folder should be automatically deleted 7 days after being placed in the XYZ folder. I want to implement this. Unfortunately, the script I pasted in my first post does not work – please point out the error if you are able to help.
M52B28
1 Rookie
•
5 Posts
0
September 26th, 2025 06:55
@Skymaster64 Hi Mate, Thank you for your reply.
Finally I created a script that works:
#!/bin/bash
FOLDER="/ifs/ZZZ/test-folder/"
LOG="/ifs/ZZZ/delete_log_$(date +%F).log"
# Delete files older than 7 days and write logfind
#find "$FOLDER" -print -delete >> "$LOG" 2>&1
find "$FOLDER" -mindepth 1 -mtime +7 -print -delete >> "$LOG" 2>&1
The script works after manual execution. I added it to crontab (/etc/crontab) on PowerScale, but it did not run at the scheduled time. I used the following syntax:
48 23 * * * root bash /ifs/scripts/delete_old_files.sh >> /ifs/logs/myscript.log 2>&1