kill a process that has been started using ./xxxxxxxxxxxx.sh using pkill - process

I am using Ubuntu 16.04 LTS. I run pycharm on remote desktop using ssh by:
cd /home/user/Documents/pycharm-community-2016.3/bin/ && ./pycharm.sh
I need to kill this process. For other process like firefox, I use the following:
pkill firefox
How do I kill the pycharm using pkill ?
Or is there any more elegant way to get this done ?

Following is the route that worked for me.
Step 1: remote login
Step 2:
use
top
to get process id (pid) of process associated with pycharm.
The process is java.
Step 3: use kill pid to kill the process.

Related

How to run Selenium server (RC) via Jenkins on a virtual machine?

I'm trying to automate tests using Jenkins. The principle of operation is as follows:
There is a main machine (ubuntu 22) on which tests (pyTest) are stored and virtual machines (Ubuntu 18 and 20) are created, and jenkins is connected to the main machine.
The problem is the following, I am trying to run Selenium Server from Jenkins on a virtual machine by running the command:
sh '''ssh user#ip java -jar ~/selenium_driver/selenium-server-4.3.0.jar standalone -p 1234 > logs.log 2>&1'''
Although I got rid of the data output to the console, but the step in jenkins still "freezes" waiting for the command to complete and does not proceed to the next step.
How can this problem be solved? To perform the next step, after executing the selenium server startup command. Maybe you can move on to the next step without waiting for the previous one to be completed. I use PipeLine
Decided so:
stage('NameStage') {
timeout(time: 20, unit: 'SECONDS') {
sh """
ssh user#ip 'java -jar ~/selenium_driver/selenium-server-4.3.0.jar standalone -p 1234 > ~/logs.log 2>&1'
"""
}
}
After 20 seconds, the step is completed, while selenium remains working in the background

can't start rabbitmq-server after installation

I'm trying to use rabbitmq for a django tutorial but when I want to start the server I get this error:
~$ sudo rabbitmq-server
Configuring logger redirection
14:49:57.041 [error]
14:49:57.044 [error] BOOT FAILED
BOOT FAILED
14:49:57.044 [error] ===========
===========
14:49:57.044 [error] ERROR: could not bind to distribution port 25672, it is in use by another node: rabbit#wss
ERROR: could not bind to distribution port 25672, it is in use by another node: rabbit#wss
14:49:57.045 [error]
14:49:58.046 [error] Supervisor rabbit_prelaunch_sup had child prelaunch started with rabbit_prelaunch:run_prelaunch_first_phase() at undefined exit with reason {dist_port_already_used,25672,"rabbit","wss"} in context start_error
14:49:58.046 [error] CRASH REPORT Process <0.153.0> with 0 neighbours exited with reason: {{shutdown,{failed_to_start_child,prelaunch,{dist_port_already_used,25672,"rabbit","wss"}}},{rabbit_prelaunch_app,start,[normal,[]]}} in application_master:init/4 line 138
{"Kernel pid terminated",application_controller,"{application_start_failure,rabbitmq_prelaunch,{{shutdown,{failed_to_start_child,prelaunch,{dist_port_already_used,25672,\"rabbit\",\"wss\"}}},{rabbit_prelaunch_app,start,[normal,[]]}}}"}
Kernel pid terminated (application_controller) ({application_start_failure,rabbitmq_prelaunch,{{shutdown,{failed_to_start_child,prelaunch,{dist_port_already_used,25672,"rabbit","wss"}}},{rabbit_prelau
Crash dump is being written to: erl_crash.dump...done
I've searched for port to see that if it's in use or not and I used lsof -i :25672 and I get nothing.
I don't know too much about these things so if you need anything please tell me.
Try:
sudo lsof -i :25672
sudo kill <PID>
sudo rabbitmq-server
Where <PID> is the process ID that is occupying port 25672
I have encountered this issue. I figured out that this issue is coming because the rabbitmq-server is already running on the machine.
I have used the following command
rabbitmqctl.bat status to know the status of the rabbitmq-server. This helped me to know if the server is up or down.
If it is up, this could the reason you are getting the error that you have specified in your post.
You can issue the following command to make the server down
rabbitmqctl.bat stop
Now you can try starting the rabbitmq-server by issuing the following command
rabbitmq-server start
Note that I am using Windows. And I have executed these commands by pointing the command prompt to C:\Program Files\RabbitMQ\rabbitmq_server-3.8.14\sbin as my rabbitmq installation directory is C:\Program Files\RabbitMQ\rabbitmq_server-3.8.14.
I have encountered this before. Here is what caused it and how I fixed it:
This is one of those commands which requires the magic word sudo (i.e it needs a superuser privilege).
If you forget to add sudo to the command, it begins the process but later fails when it hits a superuser-only roadblock. This leaves you with an incomplete process. Now when you decide to add sudo, it attempts the same process again but finds out that someone without the right privilege has made a mess or is still messing around.
Then the solution will be to cancel out whatever the first command has started and try again.
sudo lsof -i :25672
This list out details about the port 25672
You will see the PID (process ID) e.g 1301
Then stop the process on that port with:
sudo kill <PID>
for example, sudo kill 1301
And make sure you are killing the right process if not you may get into trouble.
Now, retry the command with sudo:
sudo rabbitmq-server
ALSO,
In most cases, this error occurs because without deliberately stopping the rabbitmq-server, it always keeps running even after you restart you system.
another way to stop rabitmq server windows+R then type "services.msc" and then find for RabitMq.slelect and stop from left top corner.
Then re run your rabitmq server.
-Hi guys, I am putting up an answer that can help Googlers to run multiple rabbitmq-server on the same machine. Trying to achieve the latter, I ran into a similar error reported in the first place and solved that by defining:
export RABBITMQ_DIST_PORT=anything_other_than_25672
as stated in the documentation:
https://www.rabbitmq.com/networking.html#epmd-inet-dist-port-range
if you are using windows go to task manager and stop rabbitmq from running...
then reload the rabbitmq-server
For Linux others answered but in Windows you should press Ctrl+Alt+delete and select task management and in that end proccess that depends on erlang.
Note that it requires Administrator previlage.
Now enter this command to start rabbitmq-server:
rabbitmq-server start
Every time you restart your computer you should do these steps.For prevent do them again you should stop rabbitmq service from startup services.
went through same problem in windows, it is already running after installation as a service
so just enable the plugins from the rabbitmq commandline by entering the code as
rabbitmq-plugins enable management_plugin
than go to the localhost:15672 and good to go.
This means that your port 25672 is already in use
try: -
sudo lsof -i :25672
sudo kill <PID>
and now start your rabbitmq server using
sudo rabbitmq-server

Stop Selenium 3.0.1 using command line

I tryied command from older versions, but it dont seems to work.
curl "http://localhost:5555/selenium-server/driver/?cmd=shutDownSeleniumServer"
'Old' command is not working because it's part of selenium RC which is not included in selenium 3.
You should now start your nodes with -servlet org.openqa.grid.web.servlet.LifecycleServlet included, and than you can shut it down with http://yourNodeIP:port/extra/LifecycleServlet?action=shutdown
I reported this issue few months ago and it's solved so you can check it out for more details here. https://github.com/SeleniumHQ/selenium/issues/2982
If you are on linux you can kill the process running on that port by
fuser -k 5555/tcp
or netstat -plten |grep java you will get the PID of seleniumserver process.
kill -9 PID.
Also try hitting the lifecycle of selenium grid2
http://yourHubIP:port/lifecycle-manager?action=shutdown
CTRL+c from your terminal also would help.
let me know if you are looking for anything else
Assuming you are running it on *nix and the standalone server is listening on the default port (4444)... you need to:
find the PID of the process that is bound to port 4444 (use lsof command)
send that process a SIGTERM to gracefully shutdown (use the kill command)
you can achieve this with the following one-liner:
$ lsof -t -i :4444 | xargs kill

How to Close Xvfb after usage

I am running some tests in headless firefox using Xvfb. However, after my tests are finished I want to move back to normal display. But I am not able to do that .Here is What I am doing .
Open A Terminal
sudo Xvfb :10 -ac &
export DISPLAY=:10
Execute My Tests using RobotFramework+ Selenium
After step 4, I want to open the firefox in the same terminal but I am not able to see it as it is directed towards :10 display.
I wonder how can I shut this (xvfb :10) down so that I can open firefox and view it.
the & on the end of your 2nd command tells Linux to run it command in background. You can see the list of background commands running with $ jobs. Sample on Ubuntu16.04:
$ sudo Xvfb :10 -ac &
[1] 31294
$ jobs -l
[1]+ 31294 Running sudo Xvfb :10 -ac &
As you can see on the output above, jobs -l shows the background job and the second column of the output is the PID that can be used to kill it as $ sudo kill 31294.
Another option that may be "cleaner" is to start Xvfb just to run the command you want and quit automatic instead of keep it running in background. This way you would replace your lines 2,3 and 4 by:
xvfb-run python my_selenium_tests.py
Just replace python my_selenium_tests.py with whatever way to run your tests. It will open Xvfb just to it and close at the end.
The simple solution is to keep the old value of DISPLAY, change it to point to the xvfb, and then after the test is run you can change it back to the saved value.
This leaves the xvfb running, so you should also get the pid of that process and kill it. Otherwise, if you run this set of steps a dozen times, you'll have a dozen xvfb processes running in the background.

Keep scrapyd running

I have scrapy and scrapyd installed on a debian machine. I log in to this server using a ssh-tunnel. I then start scrapyd by going:
scrapyd
Scrapyd starts up fine and I then open up another ssh-tunnel to the server and schedule my spider with:
curl localhost:6800/schedule.json -d project=myproject -d spider=myspider
The spider runs nicely and everything is fine.
The problem is that scrapyd stops running when I quit the session where I started up scrapyd. This prevents me from using cron to schdedule spiders with scrapyd since scrapyd isn't running when the cronjob is launched.
My simple question is: How do I keep scrapyd running so that it doesn't shut down when I quit the ssh session.
Run it in a screen session:
$ screen
$ scrapyd
# hit ctrl-a, then d to detach from that screen
$ screen -r # to re-attach to your scrapyd process
You might consider launching scrapyd with supervisor.
And there is a good .conf script available as a gist here:
https://github.com/JallyHe/scrapyd/blob/master/supervisord.conf
How about ?
$ sudo service scrapyd start