bash commands to change processor


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting bash commands to change processor
# 1  
Old 08-10-2012
bash commands to change processor

Say you got a for loop where each execution has 0 dependence on the other. Thus ideally you'd like to executed them all concurrently rather than iteratively (if you had enough CPUs). We don't quite have that many CPUs but I would like to instead partition the iterations between them.

Or maybe even partition between CPU cores.

How to do either using bash commands? Thanks
# 2  
Old 08-10-2012
You'd run the commands inside in the background, and each instance could run separately on one core. You'd have to be careful to limit it to the number of cores available.

Different commands in the same pipe chain can run concurrently with no further effort on your part, by the way.

Without seeing more details on what you want to run parallel, it's hard to give more details.
# 3  
Old 08-10-2012
I'll rephrase. Say you have:

Code:
for VARIABLE in 1 2 3 4 5 .. N
do
    command1
    command2
    commandN
done

How to tell each iteration to execute commands 1, 2, and N on a CPU and CPU core of my choosing? Lets not worry about how to partition them yet.
# 4  
Old 08-10-2012
IT would help if you gave your UNIX OS flavor, too. Output of
Code:
uname -a

You can do what you request on some different UNIXes but the commands are totally different.
# 5  
Old 08-10-2012
It's Yellow Dog Linux, although I could conceivably run it from a Red Had Enterprise Linux machine as well.
# 6  
Old 08-10-2012
Quote:
Originally Posted by stevensw
I'll rephrase. Say you have:

Code:
for VARIABLE in 1 2 3 4 5 .. N
do
    command1
    command2
    commandN
done

How to tell each iteration to execute commands 1, 2, and N on a CPU and CPU core of my choosing?
That's decided by the operating system. You run n commands simultaneously and if there's enough CPU's, it will run them concurrently.

Code:
for X in 1 2 3 4 5
do
        command &
done

wait


I don't know if there's a standard utility to do so, but 'processor affinity mask' is what you're looking for if you really want to. But there's almost never any point -- the OS knows what CPU's are busy, and you don't.
This User Gave Thanks to Corona688 For This Post:
# 7  
Old 08-10-2012
Use the taskset command. You need some privilege to use it.

The syntax is:
Code:
for i in something
do
 taskset [cpumask]  command $i  &
 taskset [cpumask]  command2 $i  &
 taskset [cpumask]  command3 $i  &
wait
done

[cpumaskl] is a hexadecimal mask : 0x00000001 is processor #1
you may also need to redirect stdout and stderr for the taskset.... & line, depending on what the command is.
Try the man page for taskset.
This User Gave Thanks to jim mcnamara For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

How to change pset.size value in processor set in Solaris zone?

Hi I have a pool name yuk-pool and its associated pset is yuk-pset. It has a min value is 20 and max value is 56. But size field has 48 value . This same pool is assign to 4 local zones. Whenever Cpu usage is high on one local zone it impact the cpu usage at other local zone as well during high... (1 Reply)
Discussion started by: sb200
1 Replies

2. Shell Programming and Scripting

Using commands within bash script

The purpose of enclosed script is to execute selected command and output success or failure in whiptail msgBox Works as expected when command returns zero to msgBox. I cannot figure out how to continue / automate my script when command expects reply to continue / terminate. I am doing it... (2 Replies)
Discussion started by: annacreek
2 Replies

3. Shell Programming and Scripting

How to run several bash commands put in bash command line?

How to run several bash commands put in bash command line without needing and requiring a script file. Because I'm actually a windows guy and new here so for illustration is sort of : $ bash "echo ${PATH} & echo have a nice day!" will do output, for example:... (4 Replies)
Discussion started by: abdulbadii
4 Replies

4. Shell Programming and Scripting

Regarding change in column numbers after some commands

Hi All, I was using some commands to: replace a column by a constant string character awk -v a=CA 'NF>1{ $3=a; print; } ' $line>$line"_1" to copy a column and paste it in another place awk '$5=$2" "$5' $line>$line"_2" to delete the extra columns awk '{for(i=1;i<=NF;i++)... (9 Replies)
Discussion started by: CAch
9 Replies

5. AIX

Change processor compatibility mode without hmc

Hello, One of my colleagues is working on a p730 without HMC, only one LPAR has all resources. The server is showing some issues with Informix (10.00 & 11.50), the same config (OS & IFX) works perfectly on Power6 so I would like to ask him to change the processor compatibility mode to power6 on... (3 Replies)
Discussion started by: fapl
3 Replies

6. Shell Programming and Scripting

Bash scripts as commands

Hello, the bulk of my work is run by scripts. An example is as such: #!/bin/bash awk '{print first line}' Input.in > Intermediate.ter awk '{print second line}' Input.in > Intermediate_2.ter command Intermediate.ter Intermediate_2.ter > Output.out It works the way I want it to, but it's not... (1 Reply)
Discussion started by: Leo_Boon
1 Replies

7. Shell Programming and Scripting

Can BASH execute commands on a remote server when the commands are embedded in shell

I want to log into a remote server transfer over a new config and then backup the existing config, replace with the new config. I am not sure if I can do this with BASH scripting. I have set up password less login by adding my public key to authorized_keys file, it works. I am a little... (1 Reply)
Discussion started by: bash_in_my_head
1 Replies

8. Shell Programming and Scripting

running commands from outside of bash

Hello all! I have two consoles.I know the PID of these two.Now I want to execute a command in console#1 but from console#2. How can I achieve this? Anyone can do something for my query? Click here if you can't understand my query or to know the need for this query. (3 Replies)
Discussion started by: rakabarp
3 Replies

9. AIX

LPAR processor/virtual processor settings

Question is on setting of Physical and Virtual processors for LPARs to make proper use of virtualization capabilities. Environment is a 8-way p570 with 4 LPARs. lparVIO1 and lparVIO2: AIX 5300-04-01 Mode/Type= Shared-SMT/Capped Minimum Processors= 0.10 Desired Processors= 0.50 Maximum... (1 Reply)
Discussion started by: guttew
1 Replies

10. Linux

Commands for OS patch, processor and disk partition

Hi All, Can anybody please help me with finding commands on LINUX for the following: processor: Availability PowerManagementSupported Description also for OS patch i need to know the following info: SeverityRating ServicePackInEffect for disk partition: Description BlockSize ... (1 Reply)
Discussion started by: Veenak15
1 Replies
Login or Register to Ask a Question