How do I delete one week old files in UNIX?

How do I delete one week old files in UNIX?

You could start by saying find /var/dtpdev/tmp/ -type f -mtime +15 . This will find all files older than 15 days and print their names….4 Answers

  1. -exec rm -f {} \; (or, equivalently, -exec rm -f {} ‘;’ ) This will run rm -f on each file; e.g.,
  2. -exec rm -f {} +
  3. -delete.

How do I delete 10 days old files in UNIX?

3 Answers

  1. ./my_dir your directory (replace with your own)
  2. -mtime +10 older than 10 days.
  3. -type f only files.
  4. -delete no surprise. Remove it to test your find filter before executing the whole command.

How do I delete old logs?

Delete Old Directory Recursively In that case we will use Linux rm command with find command. The below command will search all directories modified before 90 days under the /var/log directory. Here we can execute the rm command using -exec command line option. Find command output will be send to rm command as input.

How to delete files older than X days?

Function that can be used to remove files older than a specified age and also remove empty folders. Specifies the target Path. Specifies the target Age in days, e.g. Last write time of the item. Switch parameter that allows for hidden and read-only files to also be removed.

How to delete shell scripts back to current date?

Closed 7 years ago. I’m new to shell scripts, can anyone help? I want to delete scripts in a folder from the current date back to 10 days. The scripts looks like: The script will run in every 10 day with Crontab, that’s why I need the current date. -delete no surprise. Remove it to test your find filter before executing the whole command

Is there a way to delete old files in PowerShell?

The -EmptyFolders switch branches the function so that it will only perform its empty folder cleanup operation, it will not affect aged files with this switch. It is recommended to first perform a cleanup of the aged files in the target path and them perform a cleanup of the empty folders.