I'm trying to close / kill Genymotion emulator within terminal , the thing is that kill player is not enough , the vm is still running , I need something that also can kill the vBox's vm instance.
Genymotion has a command line tool (gmtool) to control the whole software. Here is the doc: https://docs.genymotion.com/Content/04_Tools/GMTool/GMTool.htm
You can simply run this command to stop a device:
gmtool admin stop myDevice
Caution: This is a paid feature
Use player utility (located at genymotion/bin directory) with options --vm-name and --poweroff
Sample:
player -n MyEmylator -x
Also maybe helpfull my simple script genymotion_tools.sh
Related
I have a bash script which will take 5-6 hrs to complete and yesterday i accessed aws 12 month free tire and running ec2 (ubuntu) on it ,i want to run that bash script even after i close my main machine ...how can i do this ?
Assuming this is on linux system, you can run your script in the background using & optons. Something like this
yourBashScript.sh &
Where & tells the shell to run it in the background. So even if you close the shell or end your ssh session, it will keep running in the background till it finishes the job or crashes due to any error.
You can always check whether your script is running or not using ps command. Something like this
ps -eaf | grep yourBashScript
this may return the process information for your script, if it is in running state.
I have a bash script. I would like to run it continuously on google cloud server. I connected to my VM via SSH in browser but after I've closed my browser, script was stopped.
I tried to use Cloud Shell but if I restart my laptop, script launches from start. It doesn't work continuously!
Is it possible to launch my script in google cloud, shut down laptop and be sure what my script works?
The solution: GNU screen. This awesome little tool let's you run a process after you've ssh'ed into your remote server, and then detach from it - leaving it running like it would run in the foreground (not stopped in the background).
So after we've ssh'ed into our GCE VM, we will need to:
1. install GNU screen:
apt-get update
apt-get upgrade
apt-get install screen
type "screen". this will open up a new screen - kind of similar in look & feel to what "clear" would result in.
run the process (e.g.: ./init-dev.sh to fire up a ChicagoBoss erlang server)
type: Ctrl + A, and then Ctrl + D. This will detach your screen session but leave your processes running!
feel free to close the SSH terminal. whenever you feel like it, ssh back into your GCE VM, and type screen -r to resume your previously detached session.
to kill all detached screens, run:
screen -ls | grep pts | cut -d. -f1 | awk '{print $1}' | xargs kill
You have the following options:
1. Task schedules - which involves cron jobs. Check this sample. Via this answer;
2. Using startup scripts.
I performed the following test and it worked for me:
I created an instance in GCE, SSH-d into it and created the following script, myscript.bash:
#!/bin/bash
sleep 15s
echo Hello World > result.txt
and then, ran
$ bash myscript.bash
and immediately closed the browser window holding the SSH session.
I then waited for at least 15 seconds, re-engaged in an SSH connection with the VM in question and ran $ ls and voila:
myscript.bash result.txt
So the script ran even after closing the browser holding the SSH session.
Still, technically, I believe your solution lies with 1. or 2.
You can use
nohup yourscript.sh > output_log_file.log
I faced similar issue. I logged into Virtual Machine through google cloud command on my local machine, tried to exit by closing the terminal, It halted the script running in the instance.
Use command exit to log out of cloud consoles in local machine putty console (twice).
Make sure you have not enabled "PREEMPT INSTANCE" while creating a VM instance.
It will force to close the instance within 24 hours to reduce the costing by a huge difference.
I have a NodeJS project and I solved with pm2
I am trying to launch a Qt message box every minute. I added a line in crontab to run the Qt program's executable and redirected the error output to a file in my home directory.
There is no problem with the Qt program that launches the message box because I tested it, but when I try to launch it with crontab the following error arises:
QXcbConnection: Could not connect to display
Aborted (core dumped)
I checked that over the internet and found a thread that might be helpful: https://unix.stackexchange.com/questions/148945/could-not-connect-to-display-in-one-user-account/149026#149026
I believe the first response gives the solution but it's not clear.
It suggests to use x11 to share the desktop and xauth to add security measures but doesn't specify how to configure them. I have xauth already installed but the error persists.
Any ideas about how to solve this problem?
I think the DISPLAY environment is missing. I suggest you wrap your application in a wrapper script (let's call it horloge.sh):
#!/bin/sh
DISPLAY=:0
export DISPLAY
/home/salwa/computing/cpp/horloge
Then put the horloge.sh in your crontab. Don't forget to do a chmod u+x horloge.sh so that the script is executable.
Make sure that the user that launches your app in the crontab line is you. Otherwise, it may not have permissions to use the X server.
I have a script built to log historical data into an Amazon Redshift instance. The script will likely need to run for a very long time, perhaps over 24 hours before it can run to completion.
I have tried ssh-ing into my EC2 instance and running the script from there, however the after a few hours I leave my laptop or shut the lid and the pipe is broken, stopping the script before it runs to completion.
How can I get a script running on my EC2, and then never have to worry about it stopping execution prematurely?
nohup yourshellcommandhere &
Will run in the background and not require you to have an interactive ssh session active.
Like #johncorser mentioned, use Screen:
You can log out and re-attach the screen later on.
yum install screen or apt-get install screen
Then just type screen.
It'll give you a "virtual" shell, which you can "detatch".
Try:
screen
sleep 999
CTRL-a then d
You can log out and back in again, and do screen -r to re-attach the virtual terminal.
Most of screen's hotkeys start with CTRL-a (lowercase a), then some letter.
If you're just going to learn one, learn CTRL-a, ? which displays help screen and list the other keys.
Another incredibly useful hotkeys:
CTRL-a, c: creates another virtual terminals
CTRL-a, n: cycles through all your virtual terminals
Just remember CTRL-a, ? and then try them all :)
I figured out how to run my Django application via sudo python /home/david/myproject/manage.py runserver 68.164.125.221:80. However, after I quit terminal, the server stops running.
I tried to run this process in the background, but the server just shuts down quickly after I execute sudo python /home/david/myproject/manage.py runserver 68.164.125.221:80 &.
How do I keep my Django application running even after I quit my ssh session in terminal?
PS - Sorry if this question strikes you as elementary. Such sillyness ensues when a front-end javascript programmer must turn into a server administrator in break-neck speed.
Meet screen.
Connect through ssh, start screen. This open a virtual console emulator on top of the one provided by ssh. Start your server there.
Then press Ctrl-a, then d. This detach the screen session, keeping it running in the background.
To [R]e-attach to it, use screen -r.
If screen is not installed and you can't install it, you can also start an application in the background by adding a & to the command, as you tried. But you should not close the terminal window then ; just disconnect, with the bash command exit, or Ctrl-d.
The advantage of screen is that you can still read the output from the server, in case there is an error or anything.
Screen is a really powerful tool, with many more commands. You can add a new virtual window with Ctrl-a, then c (for Create) ; switch through windows with Ctrl-a, then n (next) or p (previous), ...
But you need it to be installed to use it. Since you seem to have root access, this shouldn't be a problem.
EDIT: tmux is another great solution for the same use-case.
Use screen to create a new virtual window, and run the server there.
$ screen
$ python manage.py runserver
You will see that Django server has started running.
Now press Ctrl+A and then press the D key to detach from that screen. It will say:
$ [detached from ###.pts-0.hostname]
You can now safely logout from your terminal, log back in to your terminal, do other bits of coding in other directories, go for a vacation, do whatever you want.
To return to the screen that you have detached from,
$ screen -r
To kill the django server now, simply press Ctrl+C like you would've done normally.
To terminate this current screen instead of detaching from this screen, use Ctrl+D. It will say:
$ [screen is terminating]
$
Use nohup. Change your command as follows:
nohup sudo python /home/david/myproject/manage.py runserver 68.164.125.221:80 &