Sponsored Content
Top Forums Shell Programming and Scripting How to find the shellscript which is running In background is completed or not? Post 302973288 by Don Cragun on Tuesday 17th of May 2016 06:25:06 AM
Old 05-17-2016
Quote:
Originally Posted by andy391791
Code:
ps -ef | grep  abc.sh | grep -v grep

If there is an entry then the job is still running

If there isn't then the job has completed
This is more simply and more correctly done with:
Code:
ps -ef | grep -q 'abc[.]sh'

which will give you a zero exit status if one or more copies of processes are running with a name containing the string abc.sh. Using [.] instead of just . gets rid of the need for grep -v grep and keeps strings like abcdsh from accidentally being selected.

If there might be other processes running that are named with a longer string containing abc.sh, you can avoid that problem with the more complex:
Code:
ps -ef | grep -Eq '( |/)abc[.]sh( |$)'

Note that none of these suggestions will keep this from mistakenly indicating that abc.sh is running if any process is running with an argument that is abc.sh.
This User Gave Thanks to Don Cragun For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to find the jobs running in background and stop

Hi All, I have requirement. I am running a job every 30mins. before starting the process, i need to check the process, if the process is still running then i need not trigger the process again, if it is not running then trigger the process again. I am using cron to trigger the shell script. Can... (7 Replies)
Discussion started by: srinivas_paluku
7 Replies

2. Shell Programming and Scripting

running in background

i have a script called server.sh. how to run this script in backgroung using nohup command (5 Replies)
Discussion started by: ali560045
5 Replies

3. Shell Programming and Scripting

Running RSH on the background

Hi, I am developing a script that would do a 'rsh' on a client machine. I want to invoke a script in client machine which would keep on polling data to the server. I want the rsh to return back once it invoked the script on client and the script should run on background on client. ... (2 Replies)
Discussion started by: eamani_sun
2 Replies

4. UNIX for Dummies Questions & Answers

Running the Script in Background.

Gurus, Pls. help on this to run the script in background. I have a script to run the informatica workflows using PMCMD in script. Say the script name is test.sh & Parameters to the script is Y Y Y Y The no of parameters to the bove script is 4. all are going to be a flags. Each flag will... (2 Replies)
Discussion started by: prabhutkl
2 Replies

5. Shell Programming and Scripting

Shellscript to find duplicates according to size

I have a folder which in turn has numerous sub folders all containing pdf files with same file named in different ways. So I need a script if it can be written to find and print the duplicate files (That is files with same size) along with the respective paths. So I assume here that same file... (5 Replies)
Discussion started by: deaddevil
5 Replies

6. UNIX for Advanced & Expert Users

Background job when completed

Hello - I submitted one background job last night and it completed today morning.I want to know exact time the job completed. I submitted backgroung job like this nohup cp -Rp /opt/apps/prod/proddb/proddata . & I want to know when above job completed on UNIX server.Above command... (9 Replies)
Discussion started by: Mansoor8810
9 Replies

7. Shell Programming and Scripting

run a shellscript in background after startup

hi. i need to start a shellscript AFTER full system startup the script will then run permanently in a loop checking the server every minute and in case of major hangs it just reboots the machine. i put it into /etc/rc.local file like this: #!/bin/sh -e # # rc.local # # This script is... (4 Replies)
Discussion started by: scarfake
4 Replies

8. Shell Programming and Scripting

running the script in background

I have a script called startWebLogic.sh which I was running in the background but the problem is which I used the command :- ps -elf | grep "startWebLogic.sh" | grep -v grep to find the process id but I was unable to find the process id for this script and when I checked from the front end the... (3 Replies)
Discussion started by: maitree
3 Replies

9. Shell Programming and Scripting

Running in background

Hello, I was trying to make some processes to run at background and went to a problem. First I tried just to loop in one line something like this: for i in {1..10}; do echo 'hello world' &; done; but it pops a syntax error, so I tried several ways to fix it but wasn't able to understand... (2 Replies)
Discussion started by: Rash
2 Replies

10. UNIX for Beginners Questions & Answers

Running process in the background

Hi, I have this simple c program that creates duplicate process with fork(): #include <sys/types.h> main() { if (fork() == 0) while(1); else while(1); } I tried running it in the background gcc -o test first.c test & And I got this list of running process: (4 Replies)
Discussion started by: uniran
4 Replies
aemakeflic(1)						      General Commands Manual						     aemakeflic(1)

NAME
aemakeflic - produce an animation from an aewan document SYNOPSIS
aemakeflic [-f {less|sh}] [-N] [-b] [-d <delay>] input.ae [outputfile.ext] DESCRIPTION
This utility will make an ascii animation out of an aewan document. It can currently produce animations in two formats: a shellscript which, when executed, will display the animation and a "less movie" intended to be "played" on the very popular 'less' output pager -- that is, the user will see the animation as he pages down through the file in an appropriate window size. Each layer in the aewan document is interpreted as one frame of the animation. Layer transparency and compositing are not used: each layer becomes a frame. OPTIONS
-f specifies output format - can "sh" for a shellscript or "less" for a "less movie" -N omit the initial instructions that are normally included in the resulting file. The instructions will orient the user as to how to play the file. -b disables output of color (only characters will be printed). -d delay specifies the delay between frames (for shellscript only), given in milliseconds. AUTHORS
This program is part of the Aewan Ascii Art Editor package. See aewan(1) for author information. LICENSE
Copyright (c) 2004-2005 Bruno Takahashi C. de Oliveira. All rights reserved. This program is licensed under the GNU General Public License, version 2 or, at your option, any later version. For full license informa- tion, please refer to the COPYING file that accompanies the program. SEE ALSO
aewan(1), aewan(5), aecat(1) aemakeflic (Aewan Ascii Art Editor) September 2005 aemakeflic(1)
All times are GMT -4. The time now is 05:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy