• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

learner

 
crisis ofid
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to stop program running in background
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thanks
It was my first time will take care from next time
 
Tim Holloway
Saloon Keeper
Posts: 18302
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • 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
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • 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.
 
vaibhav dobriyal
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic