Sponsored Content
Top Forums UNIX for Advanced & Expert Users Manipulate files with find and fuser not working as expected on SunOs Post 303006552 by apmcd47 on Friday 3rd of November 2017 10:33:17 AM
Old 11-03-2017
SunOS (Solaris) is not Linux. Don't expect Linux utilities to have the same behaviour as Solaris utilities of the same name. Have you checked the man page for fuser on Solaris?
Solaris:
Code:
     -s sig   Sends a signal to  each  process.  The  sig  option
              argument   specifies  one  of  the  symbolic  names
              defined in the  <signal.h>  header,  or  a  decimal
              integer  signal number.  If sig is a symbolic name,
              it is recognized  in  a  case-independent  fashion,
              without the SIG prefix. The -k option is equivalent
              to -s KILL or -s 9. No signals will be sent to ker-
              nel file consumers.

Linux:
Code:
       -s, --silent
              Silent  operation.  -u and -v are ignored in this mode.  -a must
              not be used with -s.

You will have to change the way fuser is called in the Solaris version.

Personally I would be inclined to write a script; something like:
Code:
for file in "$@"
do
   fuser "${file}" >/dev/null 2>&1 || ls -lh "${file}"
done

and call it, say, checklog, and then modify the find thus:
Code:
find /some/path -type f -name "*log*" -print | xargs checklog

Andrew

Last edited by apmcd47; 11-06-2017 at 05:50 AM.. Reason: forgot the pipe in find ... xargs line
This User Gave Thanks to apmcd47 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk not working as expected with BIG files ...

I am facing some strange problem. I know, there is only one record in a file 'test.txt' which starts with 'X' I ensure that with following command, awk /^X/ test.txt | wc -l This gives me output = '1'. Now I take out this record out of the file, as follows : awk /^X/ test.txt >... (1 Reply)
Discussion started by: videsh77
1 Replies

2. UNIX for Dummies Questions & Answers

Find command not working as expected

I have a script with a find command using xargs to copy the files found to another directory. The find command is finding the appropriate file, but it's not copying. I've checked permissions, and those are all O.K., so I'm not sure what I'm missing. Any help is greatly appreciated. This is... (2 Replies)
Discussion started by: mpflug
2 Replies

3. Shell Programming and Scripting

Find cmd not working as expected

Hi, i wan to search the file starting with Admin into the directory Output. I am running below command: find /appl/Output -name "Admin*" -prune but this command is going into the sub directories present under output. I do not want to search under sub directories. Any help will be highly... (6 Replies)
Discussion started by: Vishal123
6 Replies

4. Solaris

tr -d is not working on SunOS 5.9

i am using sunos 5.9. entityname="india\/delhi" correctpattern="<branch value=\"/`echo $entityname | tr -d '\'`/WORKAREA/\"> echo $correctpattern the output should be <branch value="/india/delhi/WORKAREA/"> This is working fine in command line but not working when i placed these... (1 Reply)
Discussion started by: millan
1 Replies

5. Shell Programming and Scripting

Find files modified in last hour sunOS 5.10

trying to find a way to locate files modified in the last hour in a shell script, unfortunately the command 'find . -mmin -60' is not supported on SunOS 5.10 (works on OpenSolaris 5.11 :mad:) Does anyone know a method of doing this in shell script on 5.10? cheers (19 Replies)
Discussion started by: rich@ardz
19 Replies

6. Solaris

SunOs 5.9: why is 'ulimit -c' not working?

I have a situation where the system is dumping a 2g causing filesystem to fill up. We identified the source and working on a solution. However, I wanted to limit the size of the 'core' file. Please examine the test scenario ... cnewtonne@mars> ulimit -f 0 cnewtonne@mars> ls -ltr core*... (2 Replies)
Discussion started by: cnewtonne
2 Replies

7. Shell Programming and Scripting

basename not working as expected from find -exec

I have the following files in a directory > ls -1 /tmp/test/dir/ file with spaces 1.ogg file with spaces 2.oggI am running the following to echo the filenames but alter the file extension on the files to .mp3 instead of .ogg ( I am going to run ffmpeg against the files ultimately, but keeping... (2 Replies)
Discussion started by: jelloir
2 Replies

8. Shell Programming and Scripting

mailx not working on SunOS 5.9

I m trying to send o/p of one file using mailx command but is not working PFB command : cat healthchecklog | mailx -s "HEALTH CHECKS" abc@jkl.com also I have checked the ps -ef for mailx which is giveing below o/p ps -ef | grep mail root 364 1 0 Jun 08 ? ... (11 Replies)
Discussion started by: Jcpratap
11 Replies

9. Shell Programming and Scripting

Some help with a find/fuser/gzip crontab job

Hello, I am trying to write a housekeeping that finds all .trc files older than x days in a given FS, checks if they are used and gzips them if they are not used by any process. I need to do it without calling any additional .sh script. I managed to make it work for Linux only: find .... (4 Replies)
Discussion started by: Valkov
4 Replies

10. UNIX for Advanced & Expert Users

Fuser alternative OR running fuser on a script

Hi, Not sure whether there is a fuser alternative or any better way to check for file in use or not. I am wanting to check whether files are in use or not before removing them. Using fuser, the awk seems to be giving me 'weird' output not to mention that it is giving me 2 lines instead of... (0 Replies)
Discussion started by: newbie_01
0 Replies
FUSER(1)						    BSD General Commands Manual 						  FUSER(1)

NAME
fuser -- list IDs of all processes that have one or more files open SYNOPSIS
fuser [-cfkmu] [-M core] [-N system] [-s signal] file ... DESCRIPTION
The fuser utility writes to stdout the PIDs of processes that have one or more named files open. For block and character special devices, all processes using files on that device are listed. A file is considered open by a process if it was explicitly opened, is the working directory, root directory, jail root directory, active executable text, kernel trace file or the controlling terminal of the process. If -m option is specified, the fuser utility will also look through mmapped files. The following options are available: -c Treat files as mount point and report on any files open in the file system. -f The report must be only for named files. -k Send signal to reported processes (SIGKILL by default). -m Search through mmapped files too. -u Write the user name associated with each process to stderr. -M Extract values associated with the name list from the specified core instead of the default /dev/kmem. -N Extract the name list from the specified system instead of the default, which is the kernel image the system has booted from. -s Use given signal name instead of default SIGKILL. The following symbols, written to stderr will indicate how files is used: r The file is the root directory of the process. c The file is the current workdir directory of the process. j The file is the jail-root of the process. t The file is the kernel tracing file for the process. x The file is executable text of the process. y The process use this file as its controlling tty. m The file is mmapped. w The file is open for writing. a The file is open as append only (O_APPEND was specified). d The process bypasses fs cache while writing to this file (O_DIRECT was specified). s Shared lock is hold. e Exclusive lock is hold. EXIT STATUS
The fuser utility returns 0 on successful completion and >0 otherwise. EXAMPLES
The command: ``fuser -fu .'' writes to standard output the process IDs of processes that are using the current directory and writes to stderr an indication of how those processes are using the directory and user names associated with the processes that are using this directory. SEE ALSO
fstat(1), ps(1), systat(1), iostat(8), pstat(8), vmstat(8) STANDARDS
The fuser utility is expected to conform to IEEE Std 1003.1-2004 (``POSIX.1''). HISTORY
The fuser utility appeared in FreeBSD 9.0. AUTHORS
The fuser utility and this manual page was written by Stanislav Sedov <stas@FreeBSD.org>. BUGS
Since fuser takes a snapshot of the system, it is only correct for a very short period of time. When working via kvm(3) interface the report will be limited to filesystems the fuser utility knows about (currently only cd9660, devfs, nfs, ntfs, nwfs, udf, ufs and zfs). BSD
May 13, 2011 BSD
All times are GMT -4. The time now is 01:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy