- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- run command concurrently within 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
Discussions
Discussions
Forums
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
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
тАО03-30-2009 11:31 PM
тАО03-30-2009 11:31 PM
Is it possible to write a script to run multiple commands concurrently? Example: perform fsck for a few file systems.
Thanks in advance
Solved! Go to Solution.
- Tags:
- background
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-30-2009 11:39 PM
тАО03-30-2009 11:39 PM
SolutionYes
#!/bin/ksh
command1 &
command2 &
command3 &
Doing this with fsck might cause I/O to go high, but it should work.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-31-2009 12:20 AM
тАО03-31-2009 12:20 AM
Re: run command concurrently within script
- Tags:
- redirect
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-31-2009 12:24 AM
тАО03-31-2009 12:24 AM
Re: run command concurrently within script
# command1 >/tmp/command1.out 2>/tmp/command1.out &
BTW, fsck on a newly created filesystem is maybe not needed and will return very quickly.
Hope this helps!
Regards
Torsten.
__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.
__________________________________________________
No support by private messages. Please ask the forum!
If you feel this was helpful please click the KUDOS! thumb below!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-31-2009 01:09 AM
тАО03-31-2009 01:09 AM
Re: run command concurrently within script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-31-2009 01:12 AM
тАО03-31-2009 01:12 AM
Re: run command concurrently within script
# command1 >/tmp/command1.out 2>/tmp/command1.out &
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-31-2009 01:18 AM
тАО03-31-2009 01:18 AM
Re: run command concurrently within script
# command1 >/tmp/command1.out 2>>/tmp/command1.out &
But you can use different files, of course.
Hope this helps!
Regards
Torsten.
__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.
__________________________________________________
No support by private messages. Please ask the forum!
If you feel this was helpful please click the KUDOS! thumb below!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-31-2009 04:01 AM
тАО03-31-2009 04:01 AM
Re: run command concurrently within script
This is a better way if all output (stdout and stderr must go into the same file):
cmd1 > /tmp/cmd1.log 2>&1 &
cmd2 > /tmp/cmd2.log 2>&1 &
The construct 2>&1 says: take stderr (file number 2) and redirect it into file number 1. Each time the command runs, it will clear the log file. To track all runs of the command, change > to >> as in:
cmd1 >> /tmp/cmd1.log 2>&1 &
cmd2 >> /tmp/cmd2.log 2>&1 &
For cumulative logs, be sure to add a timestamp, especially one that can be easily sorted or selected such as YYYYMMDD.HHMMSS. You can add this to your scripts:
echo "$(date +%Y%m%d.%H%M%S) and sime text..."
Or for applications that you can't modify, add the timestamp before running the program:
echo "$(date +%Y%m%d.%H%M%S)" >> cmd1.log; cmd1 >> /tmp/cmd1.log 2>&1 &
echo "$(date +%Y%m%d.%H%M%S)" >> cmd1.log; cmd2 >> /tmp/cmd2.log 2>&1 &
Bill Hassell, sysadmin