- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: run shell scripts sequentially.
Operating System - Linux
1752805
Members
5597
Online
108789
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
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
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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
тАО09-18-2008 10:14 PM
тАО09-18-2008 10:14 PM
run shell scripts sequentially.
Hi All,
I have a master script , which would run 4 scripts in sequence. When the first script gets executed , I need to check if a particular process has been completed. If it is completed , only then proceed with the second script.
This same rule applies to script3 and script4.
Can someone please help me out.This is the function that I wrote for the process check.
process_check ()
{
p1=`ps -ef | grep o1 |grep -v grep| wc -l`
if [ "$p1" = 0]
echo "Process not running"
return 0
else
echo "Process completed"
return 1
}
I have a master script , which would run 4 scripts in sequence. When the first script gets executed , I need to check if a particular process has been completed. If it is completed , only then proceed with the second script.
This same rule applies to script3 and script4.
Can someone please help me out.This is the function that I wrote for the process check.
process_check ()
{
p1=`ps -ef | grep o1 |grep -v grep| wc -l`
if [ "$p1" = 0]
echo "Process not running"
return 0
else
echo "Process completed"
return 1
}
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-19-2008 03:33 AM
тАО09-19-2008 03:33 AM
Re: run shell scripts sequentially.
As this is posted in the Linux section
why not use pgrep like
$ proc_is_up() { pgrep ${1:-''} >/dev/null 2>&1; }
and simply base your control flow on it like
$ if proc_is_up bla;then echo runs;else echo absent;fi
absent
$ if proc_is_up httpd;then echo runs;else echo absent;fi
runs
why not use pgrep like
$ proc_is_up() { pgrep ${1:-''} >/dev/null 2>&1; }
and simply base your control flow on it like
$ if proc_is_up bla;then echo runs;else echo absent;fi
absent
$ if proc_is_up httpd;then echo runs;else echo absent;fi
runs
Madness, thy name is system administration
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-02-2008 05:46 AM
тАО10-02-2008 05:46 AM
Re: run shell scripts sequentially.
Maybe pidof could work?
something like this:
if pidof name_of_proc; then
return 0
else
return 1
fi
If there are multiple process with the same name this probably won't work. It'll return the all the pids of all the process by that name. But if this is a unique name I would say that it's a good slim variant :)
something like this:
if pidof name_of_proc; then
return 0
else
return 1
fi
If there are multiple process with the same name this probably won't work. It'll return the all the pids of all the process by that name. But if this is a unique name I would say that it's a good slim variant :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-02-2008 06:20 AM
тАО10-02-2008 06:20 AM
Re: run shell scripts sequentially.
>>> I have a master script , which would run 4 scripts in sequence. When the first script gets executed , I need to check if a particular process has been completed. If it is completed , only then proceed with the second script.
I would then add the checking on the first script. If the process is running, exit with 0, if not, exit with 1.
Then in your master script set:
script1.sh && script2.sh
And so on.
I would then add the checking on the first script. If the process is running, exit with 0, if not, exit with 1.
Then in your master script set:
script1.sh && script2.sh
And so on.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP