i want to stop a Minecraft server (java) from an empty cmd window (in the server window, we just can type "stop" to stop the server),
because I want to automatize the start and the stop of the server with os library with :
os.system("the command i search")
I don't want to kill the task , because with this method, the server is not stopped properly, and we lost a lot of data.
As for automation of the start of the server, that's simple. Either put a shortcut to your server file in your Startup folder in Windows or put a shortcut to your run.bat file in the same folder. For shutting it down, that might be a pain. I can tell from using the os.system() method that you're using Python. Stopping the server from a clear command window is something I don't know how to do, but I did find a "life-hack" you can do. This plugin is made to automatically restart your server at a specific time of day. But you should be able to configure it to just shut down, instead of a restart. Even if you made it restart, you could make the PC it's hosted on shut down just after the server restarts. This would cause a crash, granted, but it would also save all progress.
Related
Hi guys I need your help. I have a PC which runs Lubuntu 14.10 without a monitor. The user is autologged in. I have created a Sysvinit script and installed it on /etc/init.d. My script amongst other things, starts a jar file that opens a GUI application that listens on serial port.
The problem is that I can't make the jar application start automatically on boot. Java complains that it cannot connect to the X11 display server. However this is the strange thing. If I ssh into the machine and run the script myself with sudo service it starts normally. Also if I have a monitor connected during boot, it also starts correctly by itself.
I need to have the script started without a monitor connected. It seems as if when a monitor is not connected, Xorg server isn't initiated. Does anyone have any suggestions?
Thanks
You probably need an Xorg emulator like xvfb.
I haven't tested the following on Lubuntu, but it should work:
sudo apt-get install xvfb
sudo Xvfb :10 -ac
export DISPLAY=:10
That should allow your application to run through xvfb, without having a monitor or display of any kind.
After a lot of troubleshooting, I finally managed to achieve what I wanted. The problem after all was that X server did not have enough time to load. The Xserver was started from lightdm that was an upstart service, and my script started from init.d.
It seems that if a monitor is connected X server starts earlier and my script in init.d didn't crash.
A simple sleep 10 command to stall the execution of the script until X server started did the trick. However this is a guess of time when X server will start. So a more elegant solution would be to check when the desktop starts and then launch my app. In order to achieve this I inserted the following lines before launching my script.
while [ -z $(pidof lxsession) ]; do
echo "LXSession not started yet, waiting for 2 secs"
sleep 2
done
with -z $(pidof lxsession) I check if the returned string of pidof is null. (So No PID found for process lxsession). As soon as lxsession starts, the loop is canceled and the script moves on to the execution of my java app that now finds the X server and runs normally.
Thank you all for your help. I hope other people are helped by this thread and not tortured like me!
I am using run_command shell program to run some commands on servers from client machine, this shell program runs particular command on server by socket communication. In Server side i use java program to run command on server, Normally for commands like ls , pwd it is working good , but for commands like "tail -f" though i am pressing ctrl^c to stop a command, it is not stopping in server side.
is there any way to to capture ctrl^c so that i will send some msg that kills running command on server
to kill some command on server , how can i kill only that particular command which was run from client not any other
Use kill command. For more information please refer URL Kill Command for UNIX
first of all, I assume that for some reason you cannot run kill on that run_command thing. If you can, ignore below answer.
On the server, start Process. Wrap the Process object along with an ID (auto generated). Add wrapper to a List or Map. Display the ID to user on client.
when user wants to kill process, send something like "mykill ". On server, if command.equals("mykill"), then get the Process indicated by id and call its destroy method, and remove from list. Also remove stale processes from your list (whether running or exited, just to keep your list or map from getting too big).
I am using run_command shell program to run some commands on servers from client machine, this shell program runs particular command on server by socket communication.
I assume there is a good reason you are not using putty. I also assume you can modify the code of that server.
Please note I have not tried this myself. I am just giving ideas.
May be you are looking for this
killall `pidof ProcessName`
I use Weblogic server for my application and am trying to automate data source update task.
So, I have a script (UpdateDataSource.py) which updates the data source to what I need.
Now, I need Weblogic to restart once the data source has been updated. So I am trying something like;
call wlst UpdateDataSource.py
call startWebLogic.cmd
But my question is after I update the data source through script, I do not want to directly start the weblogic server (I need to close the existing one and then start)
How do I automate the same?
I'm not very sure about your question.
1. If you want to shutdown the WLS, use shutdown command in WLST
2. if you want to start WLS in another window, add "start" before the call command, like:
start call startWebLogic.cmd
I've been making a java SE application on another computer for couple of months with Netbeans. The application uses Javas sockets and connects to another application to the another computer (or to the same) through port 4444. The application connects on the first computer perfectly to another application: runned from netbeans, runned from command line and runned from a jar file.
Now I'm continuing the project on another computer. At first I tried to run the same source on this computers Netbeans debugger. Application starts, and it connects to another application, but it stops immediately. No error messages or exceptions. The screen doesn't freeze, but neither won't the applications start to communicate with each other.
I also tried to run the applications jar file from the command line. The same problem appears. It makes connection to another app, but nothing else happens.
Finally started the application from the jar file by doubleclicking it. Now it makes a connection and starts to communicate with another.
Firewall isn't blocking the application or netbeans. I've also tried to run netbeans with firewall down, but still no results. Java has been updated on both computers. For some reasons the application runs perfectly on some computers, and on others, it does this annoying thing.
It's possible that port 4444 is used by another application.
Check this by using the netstat utility.
Your application should be configurable. I.E. port 4444 shouldn't be hard coded.
Grab a stack trace from the running application. It will tell you where the program is "stuck".
You may also benefit from adding logging to your app. This will drop statements to a file or system out/err that you can use to identify its internal state. For example; when you write to a socket:
OutputStream os = socket.getOutputStream();
while (true) {
System.out.println("write loop:enter");
os.write("machine 1".getBytes());
System.out.println("write loop:exit");
}
Good luck.
What is your way to debug Java side when nativeProcess.standardInput.write method is invoked by Flex side? I know that it is possible but don't know how?
To be able to attach your Eclipse debugger to a running Java process you need to start that process with the following Java options…
-Xdebug -Xrunjdwp:transport=dt_socket,address=8001,server=y,suspend=n
Once you have done this and have restarted the server, you can use your Eclipse to attach to the running process. From Eclipse go to the Debug manager and create a new Remote Java Application configuration for the process you want to connect to. Set the port number to 8001, the same as that of the options. You will also need to enter the hostname for the machine running the Java process. That is pretty much it…