Any alternative for mmin or cmin parameter

 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Any alternative for mmin or cmin parameter
# 1  
Old 01-19-2017
Any alternative for mmin or cmin parameter

Hi,

I need to write a shell script where I need to check whether log file is generated in last 1 hour or not. But I am getting below error in using mmin or cmin parameter with find command:

Code:
find: bad option -mmin
find: bad option -cmin

So my concern is that any alternative for mmin option is there which I can use?

Any help will be greatly appereciated.

Thanks in advance.
Moderator's Comments:
Mod Comment Please use CODE tags when displaying sample input, sample output, and code segments.

Last edited by Don Cragun; 01-19-2017 at 03:21 AM.. Reason: Add CODE and ICODE tags.
# 2  
Old 01-19-2017
Quote:
Originally Posted by Ankit Srivastav
Hi,

I need to write a shell script where I need to check whether log file is generated in last 1 hour or not. But I am getting below error in using mmin or cmin parameter with find command:

Code:
find: bad option -mmin
find: bad option -cmin

So my concern is that any alternative for mmin option is there which I can use?

Any help will be greatly appereciated.

Thanks in advance.
Moderator's Comments:
Mod Comment Please use CODE tags when displaying sample input, sample output, and code segments.
What operating system are you using?

What are the complete find commands that are generating those diagnostics?
# 3  
Old 01-19-2017
I will take care for using CODE tags in future.

The full find command I tried is as below:

CODE:

Code:
find "PATH of the file" -name '*.log' -mmin +60 -exec ls -lrt {} \;


Last edited by jim mcnamara; 01-19-2017 at 06:26 AM..
# 4  
Old 01-19-2017
We'll try again. Are you on Linux? No? It does not look like it. Then what UNIX?
# 5  
Old 01-19-2017
This is solaris: below version-

Code:
SunOS hostname 5.10 Generic_144488-12 sun4u sparc SUNW,SPARC-Enterprise


Last edited by rbatte1; 01-19-2017 at 10:51 AM.. Reason: Added CODE tags
# 6  
Old 01-19-2017
Solaris 5.10's find doesn't have fine-grained timestamp checking like GNU's find utility. A common way for dealing with this on Solaris systems is to create a file with a timestamp matching the start point you're interested in using:
Code:
touch -t YYYYMMDDhhmm /tmp/start_time

and then using:
Code:
/usr/xpg4/bin/find "file hierarchies to be searched..." -name '*.log' -newer /tmp/start_time -exec ls -lrt {} +

(Note that -exec ls -lrt {} \; executes ls once for each file selected, so the output probably will not be in time sorted order. With -exec ls -lrt {} +, ls will be executed once for a group of files, but there is still no guarantee that all of the selected files will be sorted by timestamp. But, if the number of files you're selecting is relatively small [which I would expect to be true when selecting files no more than an hour old], the selected files will probably all be listed in reverse timestamp order.)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Best Alternative for checking input parameter contains required value or not

Any good way to check if code has the required output # /sbin/sysctl net.ipv4.icmp_echo_ignore_broadcasts net.ipv4.icmp_echo_ignore_broadcasts = 1 /sbin/sysctl net.ipv4.icmp_echo_ignore_broadcasts | grep "= 1" net.ipv4.icmp_echo_ignore_broadcasts = 1 What I can think of is above, and it... (16 Replies)
Discussion started by: alvinoo
16 Replies

2. UNIX for Dummies Questions & Answers

Find command mmin

Hi, Please tell me what the below command wil do, according to my understanding it finds files in the current and sub directories whose modification time is 5 hrs and it dont zip the already zipped files who's size is more than 4K. Am I Correct? find . -type f -mmin +300 ! -name... (1 Reply)
Discussion started by: nag_sathi
1 Replies

3. Shell Programming and Scripting

Find mmin, mtime, cmin not working

Dear All, We are having the script which is creating the folder on another server if it is not present using ssh. Using scp it copies copy all pdf files from local folder to server folder. After all copy is done, Just to verify i was using the below find command find... (3 Replies)
Discussion started by: yadavricky
3 Replies

4. UNIX for Dummies Questions & Answers

Relatively simple question regarding find and cmin

Nuts and bolts: I have a log file that should be updated once every minute called OD_MEM.log. I want to add a check to my CheckSystem script that confirms that the log has been written to in the last 2 minutes. If I use the find command with cmin 1, it finds the file every time. If I use the... (2 Replies)
Discussion started by: DeCoTwc
2 Replies

5. Shell Programming and Scripting

mmin not working in ksh

We have created a unix shell script to read a datafiles from specific input directory in Unix. Users will be copying datafiles to the same input unix directoty. During Testing we observed Unix Shell Script also read the incomplete datafiles which is still copying by the users. As per requirement... (1 Reply)
Discussion started by: Kumari Reshma
1 Replies

6. Solaris

AIX to SOLARIS conversion - (find -cmin option)

I have a piece of code (below) in a .ksh script running on AIX. I need to convert the code to run .zsh on Solaris. Solaris's find command does not support the -cmin function. Suggestions?? The code searchs for a file (_filename) and determines if it has been written to or modified in the last... (1 Reply)
Discussion started by: nmalencia
1 Replies

7. UNIX for Advanced & Expert Users

find -cmin or fin -newer

I am running SUSE/8 and SUSE/9 on a high end server (4 CPU, 8G RAM etc) I have a huge directory structure with over 4million files in it. I have find the files that are modified (created, modified, renamed etc etc) in the last 10 minutes periodically. I have tried "find -cmin -10" and "find... (2 Replies)
Discussion started by: xxxyyyy
2 Replies

8. Solaris

Any alternative of find . -mmin 20

hi find command is not working with -mmin in Solaris Os. Do we hav any alternative to find the modified file in any specified time span ( suppose in last 1- 2 hours) Thanks (2 Replies)
Discussion started by: Prat007
2 Replies

9. HP-UX

Use of mmin

Hi, I am trying to get the list of all the log files which are created/modified 30 days ago. So i am using the following command: find "$path" -mmin +"$time"|grep ".*\{8\}\.log"|wc -w I am getting the following error: find: 0652-017 -mmin is not a valid option. Can you please help me.... (1 Reply)
Discussion started by: dnayakan
1 Replies

10. UNIX for Dummies Questions & Answers

no [find -mmin -1]

I wanna show all files like...one minute old, one hour old, five hours old and so on... in my OS (HP-UX) there's only the command .. find -name "..." -mtime -n but this is only for days, there isn't something like -mmin -n ...just don't know what to do. also the newer than option isn't... (3 Replies)
Discussion started by: svennie
3 Replies
Login or Register to Ask a Question