Skip to ContentSkip to Footer
Start of content
- Community Home
- >
- Servers and Operating Systems
- >
- Operating System - Linux
- >
- General
- >
- run shell scripts sequentially.
General
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for
-
- Forums
-
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
- HPE Blog, Austria, Germany & Switzerland
- Blog HPE, France
- HPE Blog, Italy
- HPE Blog, Japan
- HPE Blog, Middle East
- HPE Blog, Russia
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
-
Blogs
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Blog, Latin America
- HPE Blog, Middle East
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
-
Information
- Community
- Welcome
- Getting Started
- FAQ
- Ranking Overview
- Rules of Participation
- Tips and Tricks
- Resources
- Announcements
- Email us
- Feedback
- Information Libraries
- Integrated Systems
- Networking
- Servers
- Storage
- Other HPE Sites
- Support Center
- Aruba Airheads Community
- Enterprise.nxt
- HPE Dev Community
- Cloud28+ Community
- Marketplace
-
Forums
-
Blogs
-
Information
-
English
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
- Email to a Friend
- 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
- Email to a Friend
- 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
- Email to a Friend
- 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
- Email to a Friend
- 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.
End of content
United States
Hewlett Packard Enterprise International
Communities
- Communities
- HPE Blogs and Forum
© Copyright 2021 Hewlett Packard Enterprise Development LP