GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: running scripts at background by order
Operating System - HP-UX
1848993
Members
6439
Online
104040
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
Forums
Discussions
Discussions
Forums
Discussions
back
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
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
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
07-03-2002 03:09 AM
07-03-2002 03:09 AM
Hi all,
I'm trying to run a script that submit by many users. it is very important to keep the order (FIFO).
I tried the 'script | at now' and queuedefs 1j (only 1 job at a time). but when a few jobs send one after the other in short time, It does not keep the order.
any idea?
Thanks in advance,
Perez Ilan.
I'm trying to run a script that submit by many users. it is very important to keep the order (FIFO).
I tried the 'script | at now' and queuedefs 1j (only 1 job at a time). but when a few jobs send one after the other in short time, It does not keep the order.
any idea?
Thanks in advance,
Perez Ilan.
Solved! Go to Solution.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2002 03:25 AM
07-03-2002 03:25 AM
Solution
Hi,
At the beginning of your script, check whether other instances of your script are running and if they are, check the PID of these instances. At the end of your script run, check that all these PIDs have disappeared from the ps output before exiting.
Of my head (you need to test and refine):
#!/sbin/sh
PIDS=`ps -fae | grep my_script | grep -v grep | awk '{print $2}'`
... # whatever your script runs here
# Exit only when other instances have completed
pidlist=
for pid in `echo $PIDS`
do
pidlist="$pidlist -e $pid"
done
while sleep 5
do
if ! ps -fae | awk '{print $2}' | grep $pidlist >/dev/null 2>&1
then
# none of the forerunning processes are alive
exit
fi
done
Hope this helps. Regards.
Steven Sim Kok Leong
At the beginning of your script, check whether other instances of your script are running and if they are, check the PID of these instances. At the end of your script run, check that all these PIDs have disappeared from the ps output before exiting.
Of my head (you need to test and refine):
#!/sbin/sh
PIDS=`ps -fae | grep my_script | grep -v grep | awk '{print $2}'`
... # whatever your script runs here
# Exit only when other instances have completed
pidlist=
for pid in `echo $PIDS`
do
pidlist="$pidlist -e $pid"
done
while sleep 5
do
if ! ps -fae | awk '{print $2}' | grep $pidlist >/dev/null 2>&1
then
# none of the forerunning processes are alive
exit
fi
done
Hope this helps. Regards.
Steven Sim Kok Leong
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2002 03:28 AM
07-03-2002 03:28 AM
Re: running scripts at background by order
Hi,
I forgot to consider the currently running script.
Change:
PIDS=`ps -fae | grep my_script | grep -v grep | awk '{print $2}'`
To:
PIDS=`ps -fae | grep my_script | grep -v grep | awk '{print $2}' | grep -v $$`
Hope this helps. Regards.
Steven Sim Kok Leong
I forgot to consider the currently running script.
Change:
PIDS=`ps -fae | grep my_script | grep -v grep | awk '{print $2}'`
To:
PIDS=`ps -fae | grep my_script | grep -v grep | awk '{print $2}' | grep -v $$`
Hope this helps. Regards.
Steven Sim Kok Leong
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.
Company
Events and news
Customer resources
© Copyright 2026 Hewlett Packard Enterprise Development LP