how i can execute more than one command at the same time ? (OS = sun solaris)
-
Do you want to put one command in the background and start a new command or do you want to start multiple commands at the same moment? Please give some more details.– ChristianSep 7, 2010 at 11:14
-
my problem as the following :- sudo find / -type f -name fs-type –print this command shows all repository but how i can show the content of each repository ... manually method very complex so it is impossible .. so what i will do ? the solution maybe execute more than one command at the same time– Mohammad AL-RawabdehSep 7, 2010 at 11:18
3 Answers
Glad to see you're willing to learn shell as I suggested earlier in another question. :-)
To put command in background and let it execute there:
yourcommand &
To switch back to that process (if only one background process started):
fg
To list all backgrounded processes:
jobs -l
If you just want to run a command, then another, and then another ....
yourcommand && yourothercommand && youryetanothercommand
The above example would proceed to the next command only if the previous command succeeded without errors. If you don't mind if the previous command succeeded or not, you can do
yourcommand; yourothercommand; youryetanothercommand
Also, command screen
will be your new best friend. It allows you to start a process in its own "screen", which you can detach and reattach later, so you can, for example, connect to a server from your company desktop computer, start a screen and let a long-running command run there, detach the session, walk to your company laptop, connect to that server with that, and reattach the session and see what's happened meanwhile.
Anyway, all this is the kind of basics I shouldn't be explaining to you; go and read a tutorial to get started! Just Google for bash tutorials, if your shell is bash. You seem to be using Solaris, so your shell might as well be csh, in that case google for csh tutorials. They are similar to each other, but some differences do apply for example in environment variable stuff.
-
.pleas i still have a problem becouse the command need to enter password so we must enter password many many times ... i don't know if there is a method to solve this problem Sep 7, 2010 at 11:33
-
If the command is a local command asking for password and the command you are running is not ssh asking for password, "echo your_password | your_command" should work. If the command asking for password is ssh, you need to configure a password-less ssh-key, Google for that. Basically it's just "ssh-keygen -t rsa" and "ssh-copy-id -i ~/.ssh/id_rsa.pub youruser@yourhost" Sep 7, 2010 at 11:53
-
You're not trying to execute two commands at once, but rather, you wish to run a second command on the ouput of the first. SvenW has mentioned the -exec argument to find already, but another way is to use xargs, which allows you to use the output of a piped command as an argument to another command.
Let's say that you'd like to find every directory named foo, and see permissions on any files within that directory:
find / -type d -name 'foo' -print0 | xargs -0 ls -la
(See the man pages for find and xargs for use of -print0 and -0 if needed.)
Please explain what you want to do, because there are so many ways to do this.
- You can chain commands like
command1; command2
- You can put long running commands in the background with & like
command &
- You can use screen (highly recommended,
man screen
) to have multiple virtual consoles running at the same time, even after you disconnect. - You can write shell scripts
- etc.etc.
Read any Linux/Unix beginners guides, this will be explained in great detail.
Also, this is not a beginners forum to learn the fundamentals. The type of questions you ask is better suited on the sister site superuser.com.
-
my problem as the following :- sudo find / -type f -name fs-type –print this command shows all repository but how i can show the content of each repository ... manually method very complex so it is impossible .. so what i will do ? the solution maybe execute more than one command at the same time Sep 7, 2010 at 11:20
-
Look into
man find
, it will explain how you can tell find to execute a command for every file it finds. It goes something like this `find / -type f -name fs-type -exec yourcommand {} \`. Again, there are good tutorials out there.– SvenSep 7, 2010 at 11:26