Skip to content
Advertisement

Correct way to set a crontab to stop and start mysql and httpd

i’m trying to create a shell script to stop and start mysql and httpd every saturday on 3am, i’m doing it:

myscript.sh:

JavaScript

and setting the crontab to:

JavaScript

It’s correct way to do it? i’m stopping and starting mysql and httpd cuz use of memory, should i do some check before stop them? or i can do it without problems?

another question: how to check memory ram before stop them? like a ‘if’ memory is less than X stop them, something like it?

Thanks in advanced.

Advertisement

Answer

Presumably your MySQL workload comes from your httpd web server.

So, do this, to stop httpd first, then bounce mysqld, then restart httpd.

JavaScript

But, you should investigate carefully whether this is truly necessary. Lots of production systems don’t need it. Modern Apache servers limit the lifetime of their worker processes automatically, to handle the memory leak situation you are mentioning.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement