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.
:-) You got me there mate. This is a work around. I am trying to support my customer who is on the other side of the planet. And I cant have a remote session on his production server due to their IT Policey. I will look into your suggestion and will give you an Update. Thank you very much for your support.
---------- Post updated at 09:19 AM ---------- Previous update was at 08:43 AM ----------
Quote:
Originally Posted by methyl
Referring to post #1 (we'll ignore post #2).
The script contains a fundamental logic error. If there is more than one file matching the pattern *.pid the variable $PID contains multiple values. From that point on the script fails.
I'm not quite clear what you are trying to do here. Reading betweeen the lines, beware that deleting a ".pid" file will not stop the process with that Process ID.
The script needs restructuring to process each file in turn.
e.g.
Keep the "rm" line as an "echo" until you are happy that your script does what you want.
Noted zaxxon comments and corrected "cut" statements.
Noted that the "date" line could be better but didn't change it.
Thanks methyl. That was very educating. You are right about the process thingy. I might end up getting a zombie process.
Let me explain what is going on a bit. There is a process, or a program, called the Process Monitor. Its job is to remove the failed programs.
Whenever a process is initiated, it generates an associated monitor file (.i.e. <exename>_<programid>.pid) file. The purpose of this file is to make sure that the new instances of a program are not started if the previous instance is still running.
Before a program starts an instance, it checks if an associated monitor file exists. If one does exist, then this indicates that an instance is already running and so the program immediately exits. If a monitor file does not exist, the program starts and creates a monitor file. This file is uniquely associated to the program instance using the PRID in a common directory (the default is $OPTIMA/PIDS). When the program has run, it removes the monitor file. The Process Monitor ensures that monitor files are removed if programs crash or hang.
By the way, I tried the following set of lines and it worked but with a catch.
I have realized that the PIDS in /pids folder have the same updated time like the below figs
Quote:
total 96
Quote:
-rw-r----- 1 root sys 0 Feb 28 09:00 test.pid -rwxr-xr-x 1 root sys 15 Feb 28 23:52 optimamd_opx_LOD_GEN_110_00111010L.pid -rwxr-xr-x 1 root sys 15 Feb 28 23:52 optimamd_opx_LOD_GEN_110_001110107.pid -rwxr-xr-x 1 root sys 15 Feb 28 23:52 optimamd_opx_LOD_GEN_110_001110109.pid -rwxr-xr-x 1 root sys 16 Feb 28 23:52 optimamd_opx_LOD_GEN_110_00111010H.pid -rwxr-xr-x 1 root sys 15 Feb 28 23:52 optimamd_opx_LOD_GEN_110_00111009A.pid -rwxr-xr-x 1 root sys 15 Feb 28 23:52 optimamd_opx_LOD_GEN_110_001110106.pid #
the script will not be able to delete anyone of the pids since the time is same and the loader will see that another process is running. I have hit the wall here any advice dear?
---------- Post updated at 09:23 AM ---------- Previous update was at 09:19 AM ----------
Quote:
Originally Posted by xoops
can be done with 1 find command
Thanks mate. I tried this before even posting here. Particular flavor of the solaris dosnt support -amin or -mmin of the find command
---------- Post updated at 09:38 AM ---------- Previous update was at 09:23 AM ----------
Standard Unix file systems don't store creation time. The only times
Unix stores for files are access time, modification time, and inode
change time.
Quote:
total 96
-rw-r----- 1 root sys 0 Feb 28 09:00 test.pid
-rwxr-xr-x 1 root sys 15 Feb 28 23:52 optimamd_opx_LOD_GEN_110_00111010L.pid
-rwxr-xr-x 1 root sys 15 Feb 28 23:52 optimamd_opx_LOD_GEN_110_001110107.pid
-rwxr-xr-x 1 root sys 15 Feb 28 23:52 optimamd_opx_LOD_GEN_110_001110109.pid
-rwxr-xr-x 1 root sys 16 Feb 28 23:52 optimamd_opx_LOD_GEN_110_00111010H.pid
-rwxr-xr-x 1 root sys 15 Feb 28 23:52 optimamd_opx_LOD_GEN_110_00111009A.pid
-rwxr-xr-x 1 root sys 15 Feb 28 23:52 optimamd_opx_LOD_GEN_110_001110106.pid
Oh GOD help ... I not cut for this
Last edited by sajid.shah; 02-28-2011 at 11:08 AM..
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)