Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Delete directory older than n days Post 303046016 by mustfirst on Tuesday 21st of April 2020 04:40:12 PM
Old 04-21-2020
Delete directory older than n days

Code:
drwxr-xr-x 2 dbadmin dbadmin 4096 Apr 21 09:44 2020-04-17
drwxr-xr-x 2 dbadmin dbadmin 4096 Apr 21 09:44 2020-04-16
drwxr-xr-x 2 dbadmin dbadmin 4096 Apr 21 09:44 2020-04-20
drwxr-xr-x 2 dbadmin dbadmin 4096 Apr 21 12:39 2020-04-14
drwxr-xr-x 2 dbadmin dbadmin 4096 Apr 21 12:41 2020-04-15
drwxr-xr-x 2 dbadmin dbadmin 4096 Apr 21 12:44 2020-04-18
drwxr-xr-x 2 dbadmin dbadmin 4096 Apr 21 13:18 2020-04-21

I'm trying to delete directories older than 7 days. The directories are created by date every day and there are *.gz files inside. Whevener I compress or uncompress the *.gz files, the directory modified date changes to the current date and when I run the code, it won't delete it. This is what I have so far:

Code:
find ~/delete/* -type d -mtime +7 -exec cp -r '{}' ~/test \;

 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

delete files older than 7 days

can anyone tell me how I would write a script in ksh on AIX that will delete files in a directory older than 7 days? (1 Reply)
Discussion started by: lesstjm
1 Replies

2. Shell Programming and Scripting

delete file older than N days

Hi, All, I'd like to delete files older than 1 day. I thought the following command find /your_directory -mtime +1-exec rm -f {} \; will do the work, but not so, it seems like it won't delete files unless it is 2 days old or older. the files between 1 day and 2 days old does not... (7 Replies)
Discussion started by: ericaworld
7 Replies

3. UNIX for Dummies Questions & Answers

Delete files older than 30 days

This is driving me crazy. How can I delete files in a specifc directory that are over 30 days old? Thanks in advance. (3 Replies)
Discussion started by: tlphillips
3 Replies

4. Solaris

Delete files older than 30 days

Hi all, I want to delete log files with extension .log which are older than 30 days. How to delete those files? Operating system -- Sun solaris 10 Your input is highly appreciated. Thanks in advance. Regards, Williams (2 Replies)
Discussion started by: William1482
2 Replies

5. Shell Programming and Scripting

To delete logs older than 30 days

I want to write a shell script that deletes all log files in a directory that are older than 30 days except for 3 files: I am using the following command: find /tmp/logs -name "*.log" -mtime +30 -exec rm -f {} \;But this command deletes all the log files. How can i modify this script that... (5 Replies)
Discussion started by: mmunir
5 Replies

6. Shell Programming and Scripting

Delete files older than X days.

Hi All, I am using below code to delete files older than 2 days. In case if there are no files, I should log an error saying no files to delete. Please let me know, How I can achive this. find /path/*.xml -mtime +2 Thanks and Regards Nagaraja. (3 Replies)
Discussion started by: Nagaraja Akkiva
3 Replies

7. Shell Programming and Scripting

Delete files older than 10 Days in a directory

Hi All I want to remove the files with name like data*.csv from the directory older than 10 days. If there is no files exists to remove older than 10 days, It should not do anything. Thanks Jo (9 Replies)
Discussion started by: rajeshjohney
9 Replies

8. AIX

Want to delete directory, subdirectories and all files which are older than 7 days

how do i remove sub directories of a directory and all files which are older than 7 days by a single command in AIX. pls help me. I am using command as #find /gpfs1/home/vinod/hpc/ -depth -type d -mtime +7 -exec rm -rf {} \; so i want to delete all sub directories and all files from the... (1 Reply)
Discussion started by: vinodkmpal
1 Replies

9. UNIX for Dummies Questions & Answers

Delete file older than three days

I am using SFTP to transmit files from the Mainframe to an UNIX server. I am looking for some kind of script that runs with SFTP to delete tranmitted files older than 3 days. Can this be done in a SFTP transmission batch job? (5 Replies)
Discussion started by: Steve Carlson
5 Replies
ISCSI-INITIATOR(8)					    BSD System Manager's Manual 					ISCSI-INITIATOR(8)

NAME
iscsi-initiator -- refuse-based iSCSI initiator SYNOPSIS
iscsi-initiator [-46bcDfVv] [-a authentication-type] [-d digest-type] [-h target-hostname] [-p target-port-number] [-t target-number] [-u username] mount_point DESCRIPTION
The iscsi-initiator utility can be used to access an iSCSI target, such as iscsi-target(8), to access block storage which has been exported. Information pertaining to the target is displayed underneath the mount point, along with the device corresponding to the storage which the target exports. The various arguments are as follows: -4 Use an IPv4 connection to the target. -6 Use an IPv6 connection to the target. -a authentication-type Use the specified authentication type when communicating with the target. The possible values are chap, kerberos, srp or none. The default value is none. -b Show the storage as a block device. -c Show the storage as a character device. -d digest-type Use the specified digest type when communicating with the target. The possible values are header, data, both, all or none. The default value is none. -D List the LUNs on the specified target and exit (i.e. do discovery only) -f Show the storage as a regular file. -h hostname Connect to the iSCSI target running on the host specified as the argument. -p port-number Connect to the iSCSI target running on the port specified as the argument. The default value is 3260. -t target Connect to the number of the iSCSI target running as the argument. -u username Use the specified user's credentials when logging in to the iSCSI target. There is no default. -V Print out the version number and then exit. -v Be verbose in operation. The refuse(3) library is used to provide the file system features. The mandatory parameter is the local mount point. This iSCSI initiator presents a view of the targets underneath the mount point. Firstly, it creates a directory tree with the hostname of the target, and, in that directory, a virtual directory is created for each target name exported by the iSCSI target program. Within that virtual target directory, symbolic links exist for the hostname (for convenience), a textual representation of the IP address, the iSCSI tar- get product name, the iSCSI target IQN, the iSCSI target vendor and version number. One other directory entry is presented in the virtual target directory, relating to the storage presented by the iSCSI target. This can be in the form of a regular file, which is also the default, a block device or a character device. Please note that the iscsi-initiator utility needs the ``puffs'' kernel module loaded via modload(8) to operate. EXAMPLES
# ./iscsi-initiator -u agc -h iscsi-target0.alistaircrooks.co.uk /mnt # ls -al /mnt/target0 total 576 drwxr-xr-x 2 agc agc 512 May 11 22:24 . drwxr-xr-x 2 agc agc 512 May 11 22:24 .. lrw-r--r-- 1 agc agc 39 May 11 22:24 hostname -> iscsi-target0.alistaircrooks.co.uk lrw-r--r-- 1 agc agc 14 May 11 22:24 ip -> 172.16.135.130 lrw-r--r-- 1 agc agc 16 May 11 22:24 product -> NetBSD iSCSI -rw-r--r-- 1 agc agc 104857600 May 11 22:24 storage lrw-r--r-- 1 agc agc 43 May 11 22:24 targetname -> iqn.1994-04.org.netbsd.iscsi-target:target0 lrw-r--r-- 1 agc agc 8 May 11 22:24 vendor -> NetBSD lrw-r--r-- 1 agc agc 4 May 11 22:24 version -> 0 # SEE ALSO
puffs(3), refuse(3), iscsi-target(8) HISTORY
The iscsi-initiator utility first appeared in NetBSD 6.0. An earlier version called iscsifs was available in NetBSD 5.0 in source format only. AUTHORS
The iscsi-initiator utility was written by Alistair Crooks <agc@NetBSD.org>. BUGS
iscsi-initiator currently only supports a CHAP challenge length of 16 octets. Other initiators support up to 1024 and thus it is expected that most targets will also support such lengths. This means that CHAP compatibility with other targets apart from iscsi-target(8) is likely to be poor. To workaround this, please use authentication type none by not specifying a username with the -u option. BSD
February 22, 2011 BSD
All times are GMT -4. The time now is 02:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy