- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- check for process in shell script
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2001 07:44 PM
06-07-2001 07:44 PM
check for process in shell script
I want to check for a running process in my shell script by if this process already running the script will exit
I use
WFRUN=`ps -ef|grep wfrun|grep -v grep|head -
to check for process wfrun does it running ,
when run in prompt it will not return any strings if wfrun was not running but when I use in shell why it return PID of grep wfrun.
that mean it always think that process is running.
please help on this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2001 08:23 PM
06-07-2001 08:23 PM
Re: check for process in shell script
WFRUN=`UNIX95= ps -f -C wfrun | grep cron | awk '{print $2}'`
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2001 10:02 AM
06-08-2001 10:02 AM
Re: check for process in shell script
Run "ps -ef | grep wfrun" so you can see the output.
Once I had outbound_edi.rc checking for a process of outbound_edi.sh. But, because I searched for just outbound_edi, I got BOTH outbound_edi.rc and outbound_edi.sh processes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2001 02:44 PM
06-08-2001 02:44 PM
Re: check for process in shell script
you should do the exclusion of "grep" first, for you never
know the order of "grep" and the process you are
looking for:
ps -ef | grep -v grep | grep YOUR-PROCESS
Then it should be working.
HTH,
Wodisch
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2001 02:57 PM
06-08-2001 02:57 PM
Re: check for process in shell script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2001 01:35 AM
06-11-2001 01:35 AM
Re: check for process in shell script
we had a similar problem using ps | grep .... .
It showed up, that there is no predictable order of execution of fork and exec system calls in the processes started for the pipe. So, depending on the processor performance and shell version, the ps -ef command can report one additional process for each process in the pipe with the same name as the originating script.
To overcome this problem:
WFRUN1=`UNIX95= ps -f -C wfrun `
WFRUN=`echo "$WFRUN1"| grep cron | awk '{print $2}'`
Klaus