Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I want to start mysql with the command argument "--log=log_file_name"

What is the proper way to do that when starting it with /etc/init.d?

Would it be like this? /etc/init.d/mysql start --log=log_file_name

share|improve this question
    
No, but that should be configured in your my.cnf, not on startup. –  EEAA Jan 1 '13 at 5:49
    
Well that was.. mildly helpful. So if that's not the correct way to start it then what is? I do NOT want it to be configured in .cnf because I don't want it to start that way everytime. –  Jim Jan 1 '13 at 5:54
    
What distro is this? –  EEAA Jan 1 '13 at 5:56
    
it is debian 6. –  Jim Jan 1 '13 at 5:58

2 Answers 2

up vote 4 down vote accepted

To make it simple you can create another entry in init.d to start the mysql with that logdir path option. Make a script like /etc/init.d/mysql-log and put following entries in it:

 #!/bin/sh -e
 set -e
 COMMAND=$1
 LOG="--log=/tmp/mysql.log"
 case $COMMAND in
 start)
      /etc/init.d/mysql $COMMAND $LOG
      ;;
 stop)
      /etc/init.d/mysql $COMMAND
      ;;
 restart)
      /etc/init.d/mysql stop
      /etc/init.d/mysql start $LOG
      ;;
 *)
      exit 1
 esac

Set the log file location in the above script as per your needs and start the mysql with the following command:

/etc/init.d/mysql-log start 

This way you can use different scripts for different occasions.

share|improve this answer
    
Awesome! Thanks. :) –  Jim Jan 1 '13 at 7:43

You cannot pass arguments to services with startup scripting. Reason: there should be ONLY ONE argument being passed.

This argument consists of minimally only TWO choices:

 start     -- tells the scripting that it is being started from system startup.
 stop      -- tells the scripting that it is being STOPPED due to shutdown request

Trying to configure a system to pass arguments at boot time will make your system non-standard and the cause of later configuration errors.

Usually this type of adjustment is handled in the init.d scripting by setting up variables using the /etc/sysconfig/servicename scripting and using the '.' command to basically include them in their operation.

In otherwords, the most common process is to basically configuration files that are read-in or used by the underlying application in an init.d startup scripting. Definitely this is NOT done via adding more arguments to this type of scripting.

share|improve this answer
    
Thank you, mdpc. –  Jim Jan 1 '13 at 7:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.