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:
find: bad option -mmin
find: bad option -cmin
So my concern is that any alternative for mmin option is there which I can use?
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:
touch -t YYYYMMDDhhmm /tmp/start_time
and then using:
/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.)