LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-25-2014, 12:00 PM   #1
Ra'Jiska
Member
 
Registered: Apr 2013
Posts: 47

Rep: Reputation: Disabled
Problem with command


Hello,

Here is the thing, I am preparing a script, and the thing is I need the PID of the command I want to launch, so I do:

command&

But since this command is a kind of terminal (once launched, it waits for instructions, commands) and to continue the script I have to do a CTRL + C. I would like to have still it running while the script is getting executed.

Thanks.
 
Old 01-25-2014, 01:44 PM   #2
rosehosting.com
Member
 
Registered: Jun 2012
Posts: 222

Rep: Reputation: 62
You can run the command in a screen session, then detach from the session by pressing 'Ctrl-a + d' and the command will continue to run in background.

Please visit http://www.gnu.org/software/screen/manual/screen.html for more information about 'screen'.
 
Old 01-25-2014, 01:59 PM   #3
Ra'Jiska
Member
 
Registered: Apr 2013
Posts: 47

Original Poster
Rep: Reputation: Disabled
Thanks for your help, but my script (.sh) will be an automated triggered script so I can't do the CTRL + D (even if I could, I wouldn't do it each times).
 
Old 01-25-2014, 04:42 PM   #4
Ra'Jiska
Member
 
Registered: Apr 2013
Posts: 47

Original Poster
Rep: Reputation: Disabled
Nobody ? (Bump).
 
Old 01-25-2014, 04:54 PM   #5
paladin.michael
Member
 
Registered: Jun 2011
Location: Danbury, CT, USA
Distribution: Kubuntu, Slackware, Debian, FreePBX
Posts: 72

Rep: Reputation: 22
Does the suggestion from these pages help?
http://superuser.com/questions/58539...ted-keystrokes
http://wiki.bash-hackers.org/howto/redirection_tutorial
 
Old 01-26-2014, 05:49 AM   #6
Ra'Jiska
Member
 
Registered: Apr 2013
Posts: 47

Original Poster
Rep: Reputation: Disabled
Hey there,

I tried with Screen by launching it directly detached.
There is a problem:

The PID I get is slightly wrong (example it's like usually 1000 instead of 1003).
Thanks.
 
Old 01-26-2014, 12:05 PM   #7
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 17,933

Rep: Reputation: 3692Reputation: 3692Reputation: 3692Reputation: 3692Reputation: 3692Reputation: 3692Reputation: 3692Reputation: 3692Reputation: 3692Reputation: 3692Reputation: 3692
Quote:
Originally Posted by Ra'Jiska View Post
Nobody ? (Bump).
Bumping your own threads is fairly rude, and unless you're adding more information, TOTALLY POINTLESS; it doesn't make it more visible, but LESS.

And why don't you post what you've written/tried of your own? You say you have a script, but don't post it, so we can't help you with it...and we are NOT going to write it for you. Post what you've written/tried of your own, and we will help you. Otherwise, there are MANY tutorials you can easily find for bash scripting.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
[SOLVED] problem in tr command massy Linux - General 2 01-06-2014 06:52 AM
problem with who command dev@linuxquestion# Linux - Newbie 3 03-27-2012 08:53 AM
ed command problem moata_u Programming 3 03-23-2011 06:41 PM
problem with auditreduce command and praudit command preetishetty Linux - Security 0 12-03-2007 09:24 AM
Problem with at command xav.vijay Linux - Newbie 7 08-05-2007 04:32 AM


All times are GMT -5. The time now is 06:31 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration