LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-10-2009, 12:54 PM   #1
jamwaffles
Member
 
Registered: Mar 2008
Distribution: Ubuntu Lucid
Posts: 131

Rep: Reputation: 19
Question Running two commands symultaneously from CLI


hi. a simple problem with probably a simple answer

what i want to do is run two commands (nautilus and gedit) from the command line/shell script at the same time. i can obviously do && between them, but this requires the first app to close before moving on to the second one. i want to run both apps at the same time so i can run gedit with some project files open on it, and nautilus to browse those files/other files.

regards

james waples, 14
 
Old 02-10-2009, 01:11 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
just do a single & then, or am i missing something?
 
Old 02-10-2009, 01:20 PM   #3
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
To run a program in the background when you launch it, or from within a script, place a single & after it. "gedit &". This will free the console up for the next command.

To send an already-running process to the background, first suspend it with crtl+z, then use the bg command to start it running again as a background process. Use fg to return a background process to the foreground.

By the way, what's wrong with simply opening up two separate consoles?

Last edited by David the H.; 02-10-2009 at 01:21 PM.
 
Old 02-10-2009, 10:12 PM   #4
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
Quote:
Originally Posted by David the H. View Post
By the way, what's wrong with simply opening up two separate consoles?
You waste double amount of ram. Not only two xterm's[1] or whatever, but also 2 bash sessions instead of just one. So, if the only purpose of that session is to use it as a launcher, it makes sense to just send the processes to the background so you can reuse the same shell again.

However, the output of all the programs will be multiplexed in that terminal, which might turn it completely unreadable.

[1] You could mitigate this partially by using urxvtd/urxvtc, which has a server/client architecture. It's a pity that there isn't a similar thing for bash, because I have dozens of shell sessions open at any given time. :P
 
Old 02-10-2009, 10:47 PM   #5
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
Fair enough, although I'd say the extra burden is negligible unless your system is seriously old or underpowered. I regularly keep four or five console windows open myself and I never notice any trouble. Of course, I use konsole, which has a tabbed interface, so only one instance is needed to run all the sessions.

Have you checked out the screen program? It provides multiplexing within a single terminal.
 
Old 02-10-2009, 11:19 PM   #6
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
Quote:
Originally Posted by David the H. View Post
Fair enough, although I'd say the extra burden is negligible unless your system is seriously old or underpowered. I regularly keep four or five console windows open myself and I never notice any trouble.
Well, that's the way to think that push people to upgrade every year, even when they don't need :P That your machine can doesn't mean that you need to waste all the power. It's just silly to use 5 shells when a single one suffices. Surely your machine could also run 400 without any problem, but why do it if it's not needed?

Besides that, the weight really depends on many things. It depends on the application, in the way you compiled it, whether you use compositing or not, where you use unicode or not (very noticeable), the number of characters that will fit into the window (size of the window), the length of your scrollback buffer (also very noticeable, in fact this can be the biggest impact if you set your buffer to something insane like 100k lines), and so on.

I could easily design a config for urxvt that would blow up some hundred MBs with a few instances. Bash shouldn't be a problem though.

Quote:
Of course, I use konsole, which has a tabbed interface, so only one instance is needed to run all the sessions.
Konsole is relatively good at this. It's been long since the last time I tried, so I really can't compare the actual situation of konsole vs. urxvtd/c. Still, it can't help about the bash thing. Every new tab will spawn a new bash session (or whatever shell you use).

Quote:
Have you checked out the screen program? It provides multiplexing within a single terminal.
I use it every hour and recommend it as well. That and urxvtc are my main memory savers, since 90% of the software I run is command line based.

Last edited by i92guboj; 02-10-2009 at 11:21 PM.
 
Old 02-10-2009, 11:45 PM   #7
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
Quote:
Originally Posted by i92guboj View Post
but why do it if it's not needed?
Convenience mostly. I find it easier to work this way, both from a practical and a conceptual point of view. Having each command running in a separate instance means I don't have to concentrate to keep track of what's running where, and all I have to do is switch between windows/tabs to see what's going on. I can also tear off a tab and watch two things running side-by-side if I need to. Nothing gets buried, lost, or forgotten, and no output gets scrambled.

For me, this convenience more than makes up for the added "burden" on the machine, which as I said isn't really much of one. If I have a system that can handle it, and handle it easily, why not take advantage of it (and this isn't the most powerful of machines either, being about 5 years old now)? And for the record, I am one of those people who uses an "insanely" sized scrollback buffer (I just can't stand it when the important stuff I want to see has disappeared from the history).

But hey, if you're happier working from a single terminal, who am I to argue?
 
Old 02-10-2009, 11:52 PM   #8
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
Fair enough as well. At the end of the day, it all comes down to how you work. There's no single better method for everyone. Those who think otherwise are probably running some other OS where having options is an utopia

Cheers
 
Old 02-11-2009, 10:35 AM   #9
jamwaffles
Member
 
Registered: Mar 2008
Distribution: Ubuntu Lucid
Posts: 131

Original Poster
Rep: Reputation: 19
wow. im amazed at the feedback, and solutions and potential problems have both been taken into account. for the solutions i thank all concerned, and the shortcommings have been taken into account, but if i run

gedit & nautilus

it shouldnt take up too much ram should it?

thanks all

james
 
Old 02-11-2009, 11:20 AM   #10
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
Actually, what happened was that your thread got hijacked into a conversation about personal preference, but at least it was about the thread topic, so I guess it helped.

Your command will take up as much ram as one terminal emulator, one bash session, one gedit session, and one nautilus session need. Additional ram will be needed for the textfile you open, but unless you're working with a mammoth file, that probably won't be much. None of them are particularly "heavy" apps, so there should be plenty of overhead to run them all, unless your system is extremely ancient or underpowered. But don't ask me, just try it and see.
 
Old 02-12-2009, 10:05 AM   #11
jamwaffles
Member
 
Registered: Mar 2008
Distribution: Ubuntu Lucid
Posts: 131

Original Poster
Rep: Reputation: 19
Quote:
Originally Posted by David the H. View Post
Actually, what happened was that your thread got hijacked into a conversation about personal preference, but at least it was about the thread topic, so I guess it helped.

Your command will take up as much ram as one terminal emulator, one bash session, one gedit session, and one nautilus session need. Additional ram will be needed for the textfile you open, but unless you're working with a mammoth file, that probably won't be much. None of them are particularly "heavy" apps, so there should be plenty of overhead to run them all, unless your system is extremely ancient or underpowered. But don't ask me, just try it and see.
i agree. gedit and nautilus dont use much RAM, and neither does a bash session and seeing as i have a gig of ram and a 2.8ghz pentium 4, i dont think it will be too much of a burden on the system as a whole. also, you've hit the nail on the head with the hijacking bit lol. ah well... thanks for all the responses everyone, even if it is not associated with my original question, it has given me a bit more knowlege. thankyou all
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Interesting commands or programs for the CLI baldurpet Linux - Software 12 02-19-2009 01:30 PM
automation of CLI commands using python bharatbsharma Programming 1 03-18-2008 02:13 AM
help in linux commands in cli.. jaepi Linux - Newbie 9 04-27-2007 01:31 PM
Help on cli commands? bruno buys Linux - Software 2 08-15-2004 10:35 AM
CLI commands don't work in mandrake hnash53 Linux - Newbie 2 01-24-2004 03:37 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:25 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration