You are not logged in.
Pages: 1
I want is to shutdown apache as soon as I leave the terminal, that's how django and rails web servers work. My terminal is Terminator, OS is Xubuntu 14.04
I want to do the same thing with apache and MySQL just to be sure. After all my pc is just for testing before I upload to my vps. Therefore these services don't need to run 24/7 on my laptop. I would like to know how to do it with nginx too, sometimes I use nginx.
Last edited by Fischer (April 8 2014)
Last time I used Xubuntu, there was an Xfce program that assigns key combinations to run commands. I propose that instead of doing what you're thinking about, rather assign a key combination to kill apache.
Do you have a script for triggering the services you want, or are you using commands every time?
If you are using a script you could add a function that exits terminal and kills unwanted process knowing their PIDs
Last edited by NuclearVision (April 9 2014)
@Fischer: What you're looking for cannot be done easily. Apache was meant to be run as a daemon from the ground up, so it will never be tied to a single shell instance. It is theoretically possible to do what you want, but it'll take a lot of efforts.
If you really don't want to have a useless daemon running in the background of your machine, you can control it manually with these commands (run as root):
service apache2 start
service apache2 stop
(Note that I assume you're running Ubuntu. Also note that Ubuntu will be switching to systemd so these commands will be outdated in the near future).
If you don't want to be bothered with start/stopping the web server manually, use the dev server bundled in your favorite framework. That's exactly what it's here for :)
@NuclearVision and @Adnan you're saying that I should use an Alias? well I was looking for something else, alias is a simple solution that should work though.
@rahmu yes I know I could do that, but it's annoying, besides if I forgot to turn off apache or mysql and shut down my laptop, it will freeze. I'll try to use the dev server.
You can setup a trap in your bashrc file, for example:
trap "touch ijk;exit" 0
This will create the file ijk once you type exit or terminate the terminal with the X button for example.
Pages: 1