Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Delete directory older than n days Post 303046017 by jim mcnamara on Tuesday 21st of April 2020 05:04:46 PM
Old 04-21-2020
Based on this
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

as output from ls and using the filename to generate a touch command to change the mtime on the directory:
Code:
ls -ld | while read f1 f2 f3 f4 f5 f6 f7 dname
do
   newtime=$( echo "$dname" | awk '{ gsub("-",""); printf("%s0000", $0) } ' )
    touch -t "$newtime" $dname
done

This only changes filetimes.

Last edited by jim mcnamara; 04-21-2020 at 06:48 PM..
This User Gave Thanks to jim mcnamara For This Post:
 

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
libmms(3LIB)							Interface Libraries						      libmms(3LIB)

NAME
libmms - Media Management System library SYNOPSIS
cc [ flag... ] file... -lmms [ library... ] DESCRIPTION
Functions in this library provide access to the Media Management System (MMS). The Media Management System (MMS) is a distributed removable media management system. It is based on IEEE 1244, Media Management System (MMS). Client applications request MMS to mount and unmount cartridges and process them after they are mounted. Applications use Media Man- agement Protocol (MMP) commands to make requests. The Media Management System (MMS) client API provides basic functions that give an appli- cation the ability to connect to MMS, send commands to MMS, and interpret the responses to the commands. For a client to establish a connection to MMS, it needs to first initialize a session and then establish the connection. There are two types of sessions: synchronous A synchronous connection means that the client waits for a response for each command that it sends to MMS. asynchronous A asynchronous connections means the client can continue to send commands to MMS without waiting for a response to the com- mands. The type of session is specified with the choice of initialization function, either mms_init() or mms_ainit(). The connection is established with the hello function, mms_hello(). Within an asynchronous session, the client can also send synchronous commands. If a client's instance is configured to allow multiple sessions, the client can create more than one session, in any combination of syn- chronous and asynchronous types. The client must manage which commands are sent over which session. If the client's instance is not configured to allow multiple sessions and a second init function is called, the client's hello function receives an "unwelcome" response from MMS. Any command sent using the asynchronous send function, mms_send_acmd(), specifies a callback routine that is invoked when the MMS API receives a response to the command. This callback routine is a client-specified function. A callback function can not issue other commands to MMS because the callback function is executed as part of the MMS API's reader thread. An asynchronous session allows the client to also issue commands using the synchronous send function, mms_send_cmd(), waiting for a response before returning. A client can receive notification of certain events that occur within MMS through the event notification mechanism. Routines are provided by the API to help in the processing of responses to the client's commands. For OpenSolaris platforms, libmms is released in shared object (.so) format, installed in /usr/lib/libmms.so. The following table lists libmms library routines and indicates the type of connection that supports them and whether they are optional. Routine Availability Required --------------------------------------------------------------------------------- mms_init() synchronous required for synchronous --------------------------------------------------------------------------------- mms_ainit() asynchronous required for asynchronous --------------------------------------------------------------------------------- mms_hello() synchronous and asynchronous required for both --------------------------------------------------------------------------------- mms_send_cmd() synchronous and asynchronous required for synchronous, optional for asynchronous --------------------------------------------------------------------------------- mms_send_acmd() synchronous and asynchronous required for asynchronous, optional for synchronous --------------------------------------------------------------------------------- mms_read_response() synchronous and asynchronous required for intermediate response to mms_send_cmd() --------------------------------------------------------------------------------- mms_free_rsp() synchronous and asynchronous required for both --------------------------------------------------------------------------------- mms_goodbye() synchronous required for synchronous --------------------------------------------------------------------------------- mms_agoodbye() asynchronous required for asynchronous The following routines are used by a client to to process the response to a MMS command. mms_rsp_type() Returns the type of response that was received for the command. mms_handle_err_rsp() Returns the error code and error message from an error response. mms_get_tree() Returns the parse tree of the response. mms_get_attribute() Obtains the value associcated with a attribute name from a response in namevalue mode. USAGE
To make a client application able to use MMS, build the client with access to the MMS API library routines and then configure the applica- tion. 1. Get a copy of the MMS source tree. 2. Include <mms_api.h> and <mms_sym.h> in the makefile. The path is the san-andreas/include/$(OBJ_DIR). For example, OBJ_DIR is the obj/SunOS_5.10_sparc_DEBUG. 3. Link the client to the mms library to get the MMS API. A client can link either statically or dynamically. To link the library statically, the path is san-andreas/lib/$(OBJ_DIR). To link at runtime, MMS is installed in /opt/SUNWsmmms/lib/libmms.so. 4. Link with either libcommon.so or libcommon.a depending on if the client is dynamically linked or statically linked. 5. Create the client's application name in MMS database. Client application instances must be created within MMS database in order for clients to establish a connection with MMS. 6. Use the MMS database password to connect to MMS. The default database password is a construction of the administrator password with the characters " dbadmin" appended. INTERFACES
The shared object libmms.so.1 provides the public interfaces defined below. See Intro(3) for additional information on shared object inter- faces. mms_agoodbye mms_ainit mms_free_rsp mms_get_attribute mms_get_str mms_get_tree mms_goodbye mms_handle_err_rsp mms_hello mms_init mms_read_response mms_rsp_type mms_send_acmd mms_send_cmd FILES
/usr/lib/libmms.so.1 shared object /usr/lib/64/libmms.so.1 64-bit shared object ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWmmsu | +-----------------------------+-----------------------------+ |Interface Stability |Uncommitted | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ SEE ALSO
Intro(3), mms_init(3MMS), mms_rsp_type(3MMS), mms_send_cmd(3MMS), attributes(5) SunOS 5.11 2 Dec 2008 libmms(3LIB)
All times are GMT -4. The time now is 07:56 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy