- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Test user process
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
Forums
Discussions
Discussions
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
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
01-19-2005 01:15 PM
01-19-2005 01:15 PM
I am not too understand shell script writing , could someone can help me ,
I want to have a shell script for testing , the process will run repeatly (looping), I want to test the CPU time , I have the below script to test :
while x=0
do
cp /tmp/abc.txt /tmp/def.txt
done
the process is non-stop running , but it is not fit my requirement , because the above script will generate a new process after the old process was completed , what I want is a SAME process is running non-stop (same PID ) , could someone post a script for me ? thx in advance.
could someone can post the script ? thx in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2005 01:36 PM
01-19-2005 01:36 PM
SolutionNow it's important to understand the of shell scripts. When you run a script, your current shell will start a subshell to interpret the commands in the script. Your current shell will be idle, waiting for the subshell to finish. If you want your current shell to execute all the commands in the script, use the . (dot) command. What this does is to tell your current shell to interpret the commands, not start a subshell. Here is how it is done:
. /path_to_script
Rather than type the name, you put a dot-space in front of the script name. That prevents the forking of a subshell to run your script. The terminology in Unix is called sourcing.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2005 02:02 PM
01-19-2005 02:02 PM
Re: Test user process
>> I want to have a shell script for testing, process will run repeatly (looping), I want to test the CPU time , I
As Bill already suggests, testing a user process, often to mimick a real process, is non trivial. It seems easy, but it really is not due to lack of randomness / caching / concurrency / think times and so on.
Perhaps you can articulate more clearly what you are trying to measure / mimick?
For you immediate question... any shell script will always use a fork to do a job, creating a (short lived) new process.
If you want to copy a file over and over (allthough that may seem silly to us) then you'll need a program of some sort to do so.
For example the simple perl script below:
hth,
Hein.
$in_file = shift @ARGV || die "Need input file as first argument";
$ou_file = shift @ARGV || die "Need output file as second argument";
while (1) {
open (IN,"<$in_file") || die "failed to open file $in_file for read";
open (OU,">$ou_file") || die "failed to open file $ou_file for write";
print OU $_ while (
print "$i copies\n" unless ++$i%1000;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2005 02:40 PM
01-19-2005 02:40 PM
Re: Test user process
I just want to have a script to run a process ( may be a looping ) , this process need to use the same PID . In my previous script , after the cp process finished , it will generate another process ( so the PID changed ) so not fit my requirement.
thx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2005 08:06 PM
01-19-2005 08:06 PM
Re: Test user process
do not try this unless you are sure that interrupt (normally ctrl C) works:
#!/usr/bin/sh
while true
do
a=a
done
as the above makes no I/O it will use all your cpu - but is that what you want?
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2005 08:40 PM
01-19-2005 08:40 PM
Re: Test user process
You can not have two processes running at the same time witht he same process id.
When one job completes a new process id is allocated to the next job.
Even a loop generating child processes will do this.
Regards