Find the answer to your Linux question:
Results 1 to 5 of 5
Hey guys, i need some help in my server... its CentOS (redhat alike). i need to make the server disable apache server then run mysql command to optimize the databases ...
  1. #1
    Just Joined!
    Join Date
    Sep 2010
    Posts
    4

    Cron Jobs !!?

    Hey guys,


    i need some help in my server... its CentOS (redhat alike).

    i need to make the server disable apache server then run mysql command to optimize the databases then re-enable apache server in a specific time daily.

    it it possible?


    regards.
    Ali

  2. #2
    RDU
    RDU is offline
    Just Joined!
    Join Date
    Aug 2010
    Posts
    89
    Sure, do your job in a bash scripts :
    e.g.
    /root/myscript.sh
    #!/bin/sh
    service httpd stop
    mysql ......
    service httpd start

    Make your script executable :
    chmod +x /root/myscript.sh

    Then, call your scripts from crontab

    /etc/crontab (e.g. everyday at 10:01 AM):
    01 10 * * * root /root/myscript.sh

    Then, "service crond restart"

  3. #3
    Just Joined!
    Join Date
    Sep 2010
    Posts
    4
    Quote Originally Posted by RDU View Post
    Sure, do your job in a bash scripts :
    e.g.
    /root/myscript.sh
    #!/bin/sh
    service httpd stop
    mysql ......
    service httpd start

    Make your script executable :
    chmod +x /root/myscript.sh

    Then, call your scripts from crontab

    /etc/crontab (e.g. everyday at 10:01 AM):
    01 10 * * * root /root/myscript.sh

    Then, "service crond restart"
    thank you for your reply sir,


    i have another question.
    the mysql command may take long to get done.
    does the apache server wait it until it finishes then it gets enabled in this file structure? or i have to create another file with the enable command with specific time?

  4. #4
    RDU
    RDU is offline
    Just Joined!
    Join Date
    Aug 2010
    Posts
    89
    There is no problem here. Apache don't realy wait as it's stopped. The shell scripts wait the end of the mysql command, then it startup again apache, even some hour later if needed.

    You can do another script to start but it will not be sure, as if time is too late you have unecessary downtime and if it's too early you'll start before the end of your command...

  5. #5
    Just Joined!
    Join Date
    Sep 2010
    Posts
    4
    Quote Originally Posted by RDU View Post
    There is no problem here. Apache don't realy wait as it's stopped. The shell scripts wait the end of the mysql command, then it startup again apache, even some hour later if needed.

    You can do another script to start but it will not be sure, as if time is too late you have unecessary downtime and if it's too early you'll start before the end of your command...

    yeah true

    you know ?! after i asked my question i looked at myself !!! are you really a programmer to ask a question about sequence of lines in a piece of code?

    thank you so much sir, your help is appreciated...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...