How do I gracefully stop JHS (J HTML Server) - j

This guide explains how to install and start the J html server from Jconsole, but what is the right way to kill it? C-d and C-c don't work from the console, and exit from inside the browser doesn't seem to do anything.
It just seems wrong to do a kill -9 on it.

Try:
exit''
in your browser. You should get a confirmation like:
Your J HTTP Server has exited.

Related

How do I terminate a command that runs infinitely in shell script?

I have this command in my shell script that runs forever- it wouldn't finish unless I do ctrl-c. I have been trying to look up how to send ctrl-c signal to script and all the answers have been some sort of kill $! or kill$$ or such. My problem is that the command never finishes, so it never goes on to the next command like my "kill" commands or anything else. I have to manually hit the ctrl-C in my terminal for it to even execute kill $!. I'm sure there is a way to work around this but I am not sure what. Thanks in advance!
There are several approaches to this problem. The simplest (but not most robust) is (perhaps) to simply run your long running command in the background:
#!/bin/sh
long-running-command & # run in the background
sleep 5 # sleep for a bit
kill %1 # send SIGTERM to the command if it's still running

Linux stop a command while its loading in PUTTY/SSH

Let me start of by saying i just started learning linux.
I have a command that keeps processing/loading until i press CTRL+C to cancel/stop the command and remain in session.
What i want is to send that command, wait x amount of seconds and then close it programmatically in a single command (cause i can't enter new commands when its loading). Sorry if it sounds stupid, but that would solve my problem.
Would really appreciate if someone could've helped me out here, couldn't find anything on google that was working (mostly exiting the session while the command remains loading).
Use sleep command for terminate the process.
example:
echo helloword & sleep 1 --> time indicates in seconds.After executing the echo command it will wait for one second and then it terminate the echo process
use nohup. example:
nohup ./foobar.sh & < /dev/null > ./log 2>&1
exit
In foobar.sh you can have the following content
command you wish to execute
sleep <no of seconds>
or you can use "screen", you need to install "screen" in you host, then
> screen {your-cmd}
and press ctrl+A followed ctrl+D detach current (but your cmd still running) session .

How to move a process which ppid is '1' to foreground on CentOS 6.5?

I wrote a c++ program which need lots of time to calculate, so I put it to background and set its ppid to '1'. Then I can logout and keep it running on the server.
Now I'm login to the server again, from 'top' I can see it's still running, I want to move the process to foreground then check the current output but don't know how to do it, I'm still a rookie to linux, really need your help.
The output is using '\r' to keep refresh in one line, show the rate of progress.
I tried 'jobs' and find nothing, out put is empty.
All you have to do it, run it with nohup
nohup ./a.out > your_log_file.log &
whenever you login back to server just do tail -f your_log_file.log

How to exit nodemon on a windows

I´am on a windows machine, and I understand that it is a little different here.
The problem is that I can't find any information on how I stop, kill or exit nodemon.
For purposes of completeness, The correct answer is press Ctrl + C. Or you could also find it in task manager and kill it. This applies to pretty much anything on the command line.
My experience here is that Ctrl+C leaves a node instance running in the background. If you want to kill the stack, when you try to restart 'nodemon server.js' or just 'node server.js' for that matter, you will get an EADDRINUSE error because the old node server has the port tied up. You have to find it by using ps -W | grep node in the terminal window, because the task manager wont show it. Also you can kill it with the process ID (PID) with taskkill. The /F is the 'force' parameter. Here we will kill the task with PID 7528.
$ taskkill /F /PID 7528
Then check ps -W | grep node again, and the node server should be gone, and the server will launch again.
Their docs show a few tricks on intercepting the shutdown command, but since they use a 'rs' command to restart, they could add a 'kill' command to shutdown the daemon.
Brian
I used git bash on window and I couldn't terminate the nodemon process with ctr + c, so I would terminate the node process on the task manager to use the same port. Later I found on github to why nodemon doesn't terminate in git bash. Anywaypowershell should be use instead, after ctr + c it will ask either to terminate batch job or not. This action will clear the process and stop nodemon.
Press Ctrl + C to exit from Nodemon on windows. If that does not work, simply end the task from task manager and run it again.
With the keys ctrl + c
With this you can get out of our nodemon
Or with this you can prevent the module from continuing to work
process.exit(1);
Go to --> C:\Users\username\AppData\Roaming\npm\node_modules\nodemon\bin.
In bin folder there is windows-kill.exe file.
I had issues with this until I ran command prompt as an administrator. Then Ctrl + C worked.
EDIT: Sorry, the above worked once and then stopped working. I did end up finding this article: http://www.wisdomofjim.com/blog/how-kill-running-nodejs-processes-in-windows . The command provided here (taskkill /im node.exe /F) works consistently for me on Windows, when I run it in a new command prompt window.
type .exit (it worked in my case)

Can I abort the current running bash command?

Is it possible to manually abort the currently running bash command? So, for example, I'm using 'find' but it's taking ages... how do I manually stop it?
Some things won't respond to Ctrl+C; in that case, you can also do Ctrl+Z which stops the process and then kill %1 - or even fg to go back to it. Read the section in man bash entitled "JOB CONTROL" for more information. It's very helpful. (If you're not familiar with man or the man pager, you can search using /. man bash then inside it /JOB CONTROLEnter will start searching, n will find the next match which is the right section.)
Ok, so this is the order:
1st try: Ctrl+c
2nd try: Ctrl+z
3rd: login to another console, find the process of the command within your first console that is not responding to both previously mentioned abort/sleep keystrokes with: ps aux
Then kill the process with: kill -9 <PROCESSID>
Of course there may be smarter parameters to the ps command or the possibility to grep , but this would complicate the explanation.
Press CtrlC to send SIGINT to the command to attempt to interrupt it.

Resources