so I have looked at every single script on here regarding deleting directories older than 14 days. The Script I wrote works with files but for some reason it is not deleting the directories. So here is my scripts.
#!/bin/bash
find /TBD/* -mtim +1 | xargs rm -rf
So this code successfully deleted the FILES inside TBD but it left two directories. I checked the timestamp on them and they are atleast 2 days since last modification according to the timestamp. Specifically Dec 16 16:10 So I can't figure this out. My crontab I have running this runs every minute and logs and in the log it only shows.
+ /scripts/deletebackups.sh: :2:BASH_XTRACEFD=3xargs rm -rf
+ /scripts/deletebackups.sh: :2: BASH_XTRACEFD=3find /TBD/contents TBD/contents -mtime +1
I used contents since the contents are actually peoples name in our pxe server. I checked every file and folder INSIDE these two directories and their timestamps are the same as the parent directory as they should be but it's still not deleting.
Could it be a permissions thing? I wrote the script using sudo nano deletebackups.sh When I type ls under TBD in the far left it shows drwxr-xr-x 3 hscadministrator root 4096 DEC 16 16:10 for each of the two directories that won't delete. I'm not overly familiar with what all those letters mean.
Other iterations of this code I have already attempted are
find /TBD/* -mtime +1 rm -r {} \;
To delete directories in /TBD older than 1 day:
find /TBD -mtime +1 -type d | xargs rm -f -r