This is a good reason to consider a "filing system method" for large numbers of files - create a lot of strategic sub-directories - otherwise directory commands take forever.
There is no cure for the time these commands take except to to get your directory under control.
This is one way that does not require tail, which is slower than head.
I'm writing a script to find the oldest file in a directory. I know this can be done by using ls -rt | tail -1 but these are rather large directories and that can be somewhat slow since the script will be running constantly.
Are there any other ways to do this that would be faster? I looked to... (2 Replies)
Hi all,
I need your assistance in removing the oldest file in a directory.
I posted the same thread 3 days back and I got the following answer
ls -1 -t | tail -1 | xargs rm
which is not covering the case when there are directories older than the oldest file.
So, could you please... (2 Replies)
I'm trying to write a script that will look in an /exports folder for the oldest export file and move it to a /staging folder. "Oldest" in this case is actually determined by date information embedded in the file names themselves.
Also, the script should only move a file from /exports to... (6 Replies)
I am using a bash script to perform some automated maintenance on files in a directory. When I run the script using $sh -x script.sh <directory> the script works fine. It sets the variable to the oldest file, and continues on. However when I run the script like this $./script.sh <directory>, it... (5 Replies)
Hi:-
I need help with a script I need to modify: - what's the best/easiest way to find out the oldest file in a directory and then move this file to another directory?
Thanks, (5 Replies)
Hi all,
I am a newbie to scripting and I need your help regarding finding the oldest file in a particular directory. My intention is to remove that oldest file.
Are there any options available with the "find" command to do this..
Thanks in advance for your help
Pavan (4 Replies)
Hey! I have found similar posts both here and on other sites regarding this, but I cannot seem to get my script to work. I want to delete the oldest file in a test directory if there are more than two files. My script is currently:
#!/bin/bash
MEPATH=/usr/local/bin/test
FILECOUNT=`ls... (4 Replies)
There are some 25,000 files in 7,000 directories in my source library and I am trying to find oldest files. I am running this find:
find /usr/mysrc -name "*." -type f -mtime +8000 -exec ls -l {} 2>/dev/null
and playing with the days parameter for mtime, but the output is not sorted... (3 Replies)
Discussion started by: migurus
3 Replies
LEARN ABOUT MOJAVE
db_deadlock
db_deadlock(1) BSD General Commands Manual db_deadlock(1)NAME
db_deadlock
SYNOPSIS
db_deadlock [-Vv] [-a e | m | n | o | w | y] [-h home] [-L file] [-t sec.usec]
DESCRIPTION
The db_deadlock utility traverses the database environment lock region, and aborts a lock request each time it detects a deadlock or a lock
request that has timed out. By default, in the case of a deadlock, a random lock request is chosen to be aborted.
This utility should be run as a background daemon, or the underlying Berkeley DB deadlock detection interfaces should be called in some other
way, whenever there are multiple threads or processes accessing a database and at least one of them is modifying it.
The options are as follows:
-a
When a deadlock is detected, abort the locker:
m with the greatest number of locks
n with the fewest number of locks
o with the oldest locker ID
w with the fewest number of write locks
y with the youngest locker ID
When lock or transaction timeouts have been specified:
e abort any lock request that has timed out
-h
Specify a home directory for the database environment; by default, the current working directory is used.
-L
Log the execution of the db_deadlock utility to the specified file in the following format, where ### is the process ID, and the date is
the time the utility was started.
db_deadlock: ### Wed Jun 15 01:23:45 EDT 1995
This file will be removed if the db_deadlock utility exits gracefully.
-t
Check the database environment every sec seconds plus usec microseconds to see if a process has been forced to wait for a lock; if one
has, review the database environment lock structures.
-V
Write the library version number to the standard output, and exit.
-v
Run in verbose mode, generating messages each time the detector runs.
If the -t option is not specified, db_deadlock will run once and exit.
The db_deadlock utility uses a Berkeley DB environment (as described for the -h option, the environment variable DB_HOME, or because the
utility was run in a directory containing a Berkeley DB environment). In order to avoid environment corruption when using a Berkeley DB envi-
ronment, db_deadlock should always be given the chance to detach from the environment and exit gracefully. To cause db_deadlock to release
all environment resources and exit cleanly, send it an interrupt signal (SIGINT).
The db_deadlock utility does not attempt to create the Berkeley DB shared memory regions if they do not already exist. The application which
creates the region should be started first, and then, once the region is created, the db_deadlock utility should be started.
The DB_ENV->lock_detect method is the underlying method used by the db_deadlock utility. See the db_deadlock utility source code for an exam-
ple of using DB_ENV->lock_detect in a IEEE/ANSI Std 1003.1 (POSIX) environment.
The db_deadlock utility exits 0 on success, and >0 if an error occurs.
ENVIRONMENT
DB_HOME If the -h option is not specified and the environment variable DB_HOME is set, it is used as the path of the database home, as
described in DB_ENV->open.
SEE ALSO db_archive(1), db_checkpoint(1), db_dump(1), db_load(1), db_printlog(1), db_recover(1), db_stat(1), db_upgrade(1), db_verify(1)Darwin December 3, 2003 Darwin