Setting Apache and MySQL to start/shutdown manually

All Gurus once were Newbies
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read how to get help
Post Reply
klem77
Level 1
Level 1
Posts: 9
Joined: Sun Jan 15, 2012 1:57 pm

Setting Apache and MySQL to start/shutdown manually

Post by klem77 »

Hi,

I usually use Apache+PHP+MySQL on Windows. There I set both Apache and MySQL as manually started services, so they only up and running (hence consume resources) when I actually use them. AFAIK both defaults to start on system start and only shutdown on system shutdown. Can I achieve the same setup like on Windows in Mint? How?

Thanks

User avatar
xenopeek
Level 24
Level 24
Posts: 24338
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: Setting Apache and MySQL to start/shutdown manually

Post by xenopeek »

Starting Apache and MySQL will take some additional time, but other than that if you give these services nothing to do they won't impact your system performance (they won't eat much CPU in idle; and any memory they need goes to swap). However, and you can probably do this through the GUI as well, here goes with a few commands to switch them to manual.

List all the services on your machine:

Code: Select all

initctl list
Look for the apache and mysql service name. Once you have the correct name for the apache and mysql service from that list, switch each service to manual with the following command (replace <servicename>, including the angle brackets, with the service name from the list):

Code: Select all

 echo manual | sudo tee -a /etc/init/<servicename>.override
After reboot those services will not start automatically. You can start them with:

Code: Select all

sudo initctl start <servicename>
Image

klem77
Level 1
Level 1
Posts: 9
Joined: Sun Jan 15, 2012 1:57 pm

Re: Setting Apache and MySQL to start/shutdown manually

Post by klem77 »

Thanks for the info.

I was thinking to write a shell script to start/stop those services. I note that each time I 'sudo' Mint ask for password. Are there any command that lets me set an elevated privilege once, do multiple things at that privilege, then return to normal privilege?

User avatar
xenopeek
Level 24
Level 24
Posts: 24338
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: Setting Apache and MySQL to start/shutdown manually

Post by xenopeek »

You can just sudo the shell :wink: To run a shell as superuser:

Code: Select all

sudo bash
Any commands can be run now without sudo. Type exit to return to normal shell.

Or you can just login as root:

Code: Select all

sudo -i
Image

Post Reply

Return to “Newbie Questions”