• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • Carey Brown
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • fred rosenberger
  • salvin francis

learner

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How to stop program running in background
 
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If the program in the background is cupsd:

will print a table of processes with commandname 'cupsd'.
There is a number, called 'pid' - the process-id.
with this number - assuming 1234, you may kill it:
, which is a friendly way to tell the program to stop. It may try to finish in a nice way, closing open files, database connections, ...
After two or three seconds, look whether it was killed successfully:

If it is still running, kill it with

Read 'man kill' and 'man ps' to find out more on this commands.

You will need some time to understand everything, but understanding a bit more from time to time in small steps will lead you to deeper knowledge.

Last but not least - we don't like crossposting.
But we like specific subjects, like 'stop a background process' - not 'learner'. We are all learners.

[ October 22, 2004: Message edited by: Stefan Wagner ]
[ October 22, 2004: Message edited by: Stefan Wagner ]
 
crisis ofid
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks
It was my first time will take care from next time
 
Saloon Keeper
Posts: 23892
162
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also check out "killall".

However, cupsd is a daemon, which is equivalent to a Windows Service, so you probably don't want to do a kill, you probably want it to shut down clean (unless it's locked up or something). For that, do the following:

/etc/init.d/cupsd stop

Or, for Red Hat/Fedora this also works:

/sbin/service cupsd stop
 
Stefan Wagner
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
a very good hint!
look into /etc/init.d/ whether the program is located there, and - cupsd or whatever - the 'stop' option should be used.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i think the program can be brought into foreground by
$fg
and then simply ctrl+c

i think this should work!

dobi
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes, that can work.
The full sequence is
1$ jobs
2$ fg <number>
3$ ^C

1 gives a list of jobs running as child processes for this terminal.
2 brings one of these to the foreground
3 sends a terminate signal to this program. Whether the program recognises that signal depends on how it's programmed.

It doesn't work for jobs that were started from other terminals (for example on system startup) though.
 
crisis ofid
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But i have started jobs from other terminals in background. SO how to proceed to stop it.
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
use ps -a (or ps -A if they were started by another user), grep the output to get the PID of the process you want to kill, and use kill to kill it.

For example $ ps -a | grep 'rlogin' | more will retrieve all PIDs for rlogin processes.
$kill -15 124535 will send a kill signal to process 124535, kill -9 124535 will terminate process 124535 with extreme prejudice (not even giving it time to clean up after itself).
 
Barry's not gonna like this. Barry's not gonna like this one bit. What is Barry's deal with tiny ads?
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic