How to get files which are created one hour ago in solaris 5.9 - find

I want to get files which are created one hour ago, i tried following command
/usr/bin/find /home/FILES/ -name '*.xml' -atime +.0417 -exec ls -l{} \;
In the above command .0417 is (1 day /24 hours ).
The find command which i am using does not have -mmin option.
Is there a way to get files created less one hour ago.

set the file time to 1 hours ago
touch -t 201410042236 /tmp/hourold.tmp;
/usr/bin/find /home/FILES/ -name '*.xml' /tmp/hourold -type f -exec ls -l {} \;

Related

Copy directories and their sub directories created day ago

I tried to copy Copy directories and their subdirectories created a day ago as follows:
find /application/work/ -type d -mtime -1 -exec cp -r {} /tmp/backup \;
But it is copying all directories (Not only the ones created a day ago).
Would you please advise?
find is also finding the working directory /application/work/ and is copying it, see How to exclude this / current / dot folder from find "type d". Since you're executing cp -r, it recursively copies everything in . before also copying the subset of directories you've found via -mtime. You need to set the -mindepth to exclude the working directory from the paths on which find will operate.
Modify your command to:
find /application/work -mindepth 1 -type d -mtime -1 -exec cp -r {} /tmp/backup \;

how to get number of files older than 1 hour on ksh HP-UX

I need to list set of files created older than 1 hour in certain folder of HP-UX. Following is the command i tried.
find . -type f -mmin +60 | wc -l
But it return following error for ksh
find: bad option -mmin
What is the alternative option to get number of files older than 1 hour?
Even i tried following command. Still another error. But it also work on bash
find . -type f -mtime +0.04 | wc -l
find: Error in processing the argument 0.04
find in HP-UX has no options for minutes, mtime takes days as argument.
You can create a testfile, "touch" it with the desired time and then compare with ! -newer[m]. For instance:
# onehourago=`date +"%m %d %H %M" | awk '{ onehourago=$3 - 1 ; if (onehourago<0) { onehourago=59 } printf("%.2d%.2d%.2d%.2d\n",$1,$2,onehourago,$4) }'`
# touch -t "$onehourago" testfile
# find . -type f ! -newer testfile | wc -l

find command behaves weird on AIX

Found something weird with the find command on AIX 7.1. I executed find command to list files of specific permissions. It works when I execute as below
find . -type f -perm 600 -exec ls -la {} \;
But fails to pull the files when I execute as below
find /user -type f -perm 600 -exec ls -la {} \;
Is anyone familiar with this kind of error?
Thanks,

C-shell: find file more that 12 hours

I am using solaris and i need to find file that more than 12 hours.
In solaris, there is no -mmin function. So, what i do is:
set timer = "/admin/timer.txt"
echo date > $timer
find . -type ! newer $timer
But this only work I set the script run every 12 hours.
The thing is I need to run the script every 1 hours but I couldn't find a way how to do it.
Any suggestions?
You can invoke a shell function to do the test. Something like:
now=$(perl -e 'print time')
find . -exec sh -c 'expr $1 - $(stat -f %m "$2" ) \< 43200 > /dev/null' _ $now {} \; -print

unix find and multiple commands to find all files, exclude a dir, and base results on time

Given a folder, I want to ignore a folder within, and then find all files outside that folder, whether they be folders or files, and eventually delete them via a cron style action on OS X.
On Mac OS X will use Launchd to run this, so far, I have this:
find /Users/me/Downloads -not \( -path /Users/me/Downloads/In\ Progress -prune \) -name "*" -Btime 1m
With the -Btime 1m or mime 1m I get zero results, without it i get results I can exec to rm:
find /Users/me/Downloads -not \( -path /Users/me/Downloads/In\ Progress -prune \) -name "*"
/Users/me/Downloads
/Users/me/Downloads/.DS_Store
/Users/me/Downloads/test
/Users/me/Downloads/text.txt
Eventually my criteria will be 1 week, but for now, I use 1 minute, as that surely has passed.
cd ~/Downloads
$find . -mtime 1m
$
Or
cd ~/Downloads
$find . -mtime 1m -print
$find: *: unknown primary or operator
I believe I figured it out, but if someone could look over my shoulder, I certainly would appreciate it:
/usr/bin/find /Users/$USER/Downloads -not ( -path /Users/$USER/Downloads/In\ Progress -prune -o -type d ) -mtime +1s
That finds all files in ~/Downloads at are older than 1 second(s) and are not inside the "In Progress" directory. At first, it was also locating the path /Users/$USER/Downloads as the first hit
/usr/bin/cd ~/Downloads/
echo "You are in: " $(/bin/pwd)
/usr/bin/find /Users/$USER/Downloads -not \( -path /Users/$USER/Downloads/In\ Progress -prune -o -type d \) -mtime +1s
So, can anyone tell me why it is not picking up /Users/$USER/Downloads I certainly don't mind, but I also don't like not understanding.
Finally, the last step would be, change mime to +1w and then append xargs rm -rf {} \; and I should be good to go? If I also wanted to pass in a little list of what find has found and >> it to a log file, where would be a good place to shove that?