Sponsored Content
Full Discussion: pid.cleanup script.
Top Forums Shell Programming and Scripting pid.cleanup script. Post 302500304 by zaxxon on Monday 28th of February 2011 07:26:07 AM
Old 02-28-2011
The test
Code:
if [ -e ${FOLDER}/${PID} ]

does not accept multiple values this way. Putting a set -x in the head of your script shows following:
Code:
+ '[' -e home/optima/pids/optimamd_opx_LOD_GEN_110_00111009A.pid home/optima/pids/optimamd_opx_LOD_GEN_110_001110106.pid
 home/optima/pids/optimamd_opx_LOD_GEN_110_001110107.pid home/optima/pids/optimamd_opx_LOD_GEN_110_001110109.pid
 home/optima/pids/optimamd_opx_LOD_GEN_110_00111010H.pid home/optima/pids/optimamd_opx_LOD_GEN_110_00111010L.pid ']'
./mach.ksh: line 10: [: too many arguments
+ echo -e '*.pid not found.'
*.pid not found.

I suggest to put it this way and do not test with -e if the files exist, as the loop will only run on the files that fit to the expansion anyway and sowith exist:
Code:
for f in ${FOLDER}/*pid; do
   ls_time=`...
   ...
done

You will also get problems with these kind of cuts:
Code:
cut -d\ -f 8 | cut -d\: -f 1

If you want a blank as delimeter, write it like this:
Code:
cut -d" " -f 8 ...
#or
cut -d\  -f 8 ...

In the second line there are 2 blanks so cut will know that only the following blank right after the backslash is the delimeter, not the rest of the command too. I'd suggest you take the 1st solution as it is more clear to read.

And another more general thing is, that the programs or scripts that generate those pid files, should be able to clean them up themselves. It seems that there is something not working properly and that this script is just a workaround for the real problem.
This User Gave Thanks to zaxxon For This Post:
 

10 More Discussions You Might Find Interesting

1. Programming

printing ppid,child pid,pid

question: for the below program i just printed the value for pid, child pid and parent pid why does it give me 6 values? i assume ppid is 28086 but can't figure out why there are 5 values printed instead of just two! can someone comment on that! #include<stdio.h> #define DIM 8 int... (3 Replies)
Discussion started by: a25khan
3 Replies

2. UNIX for Dummies Questions & Answers

Session PID & socket connection pid

1. If I use an software application(which connects to the database in the server) in my local pc, how many PID should be registered? Would there be PID for the session and another PID for socket connection? 2. I noticed (through netstat) that when I logged in using the my software application,... (1 Reply)
Discussion started by: pcx26
1 Replies

3. Shell Programming and Scripting

awk/sed/ksh script to cleanup /etc/group file

Many of my servers' /etc/group file have many userid's that does not exist in /etc/passwd file and they need to be deleted. This happened due to manual manipulation of /etc/passwd files. I need to do this for 40 servers. Can anyone help me in achieving this? Even reducing a step or two will be... (6 Replies)
Discussion started by: pdtak
6 Replies

4. Shell Programming and Scripting

User Cleanup Script

Hi Guys, I've got an system setup to act as an sftp server. I have a script that allows me to create chroot users running a custom shell within their home directory, it also creates a subdirectory that they can write into. I'm trying to write a script (that I can cron at a later date) that checks... (3 Replies)
Discussion started by: King_Brucie
3 Replies

5. Shell Programming and Scripting

Cleanup script

Hi! I would like to write a script which remove some files, all beginning with the same prefix : prefix.1 doc/prefix.2 ../prefix.3 etc. So, I would create a file and chmod it executable. But I dont know how to pass a variable to a script. I would like to write something like ... (2 Replies)
Discussion started by: tipi
2 Replies

6. Shell Programming and Scripting

Suggestions/cleanup Bash script

Hello, beginner bash scripter here.. I was able to write a script and it works just fine. I'm just wondering if someone could chime in or any suggestions to make it cleaner or tighter so to speak. I have a disk to disk backup solution which uses 250GB disks. When one gets full I just po in a new... (7 Replies)
Discussion started by: woodson2
7 Replies

7. Shell Programming and Scripting

Mail cleanup from ksh script, keeping 50 most recent msgs

I found some posts describing how to completely clean out a mailbox in Unix/Linux. But I want to keep the 50 most recent messages. Any ideas out there? Thanks! (3 Replies)
Discussion started by: OPTIMUS_prime
3 Replies

8. UNIX for Advanced & Expert Users

Table Cleanup Script

I needed some help with a script to fetch and delete all records prior to 3 days from now connecting to sybase from sunos. I wrote the following script but not working..can someone please guide me with my code. Thanks #!/bin/ksh ##GET PREVIOUS DAY DATE dt=`date | awk... (3 Replies)
Discussion started by: moe458
3 Replies

9. Shell Programming and Scripting

Suggestion with script to cleanup

I need help with sed and awk scripts to search for Symmetrix ID=000090009902 and then grep its child disk devices associated to the dead paths and display them only, so that those dead devices can be removed. test01:/#powermt display dev=all Pseudo name=hdiskpower0 Symmetrix ID=000090009902... (0 Replies)
Discussion started by: aix_admin_007
0 Replies

10. Shell Programming and Scripting

UNIX script for cleanup

Hello, I need some help from unix guru's here..I am looking for some advanced level script to cleanup the directories and files from specific directories under a file system.. The folders are created under /opt/modules And under modules, there are multiple subfolders with the application... (6 Replies)
Discussion started by: mb525
6 Replies
asadmin-delete-domain(1AS)					   User Commands					asadmin-delete-domain(1AS)

NAME
asadmin-delete-domain, delete-domain - deletes the givendomain SYNOPSIS
delete-domain [--terse=false] [--echo=false] [--domaindir install_dir/domains] domain_name delete-domain deletes the specified domain. The domain must already exist and must be stopped. This command is supported in local mode only. OPTIONS
--domaindir directory where the domain is to be deleted. If specified, path must be accessible in the filesystem. If not speci- fied, the domain in the default install_dir/domains directory is deleted. --terse indicates that any output data must be very concise, typically avoiding human-friendly sentences and favoring well- formatted data for consumption by a script. Default is false. --echo setting to true will echo the command line statement on the standard output. Default is false. OPERANDS
domain_name name of the domain. Must be a unique name. Example 1: Using delete-domain asadmin> delete-domain sampleDomain deleted domain sampleDomain successfully Where: the sampleDomain domain is deleted. EXIT STATUS
0 command executed successfully 1 error in executing the command asadmin-create-domain(1AS), asadmin-start-domain(1AS), asadmin-stop-domain(1AS), asadmin-list-domains(1AS) J2EE 1.4 SDK March 2004 asadmin-delete-domain(1AS)
All times are GMT -4. The time now is 06:21 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy