Linux: How to pass parameters to `service foo start` (at command line)?

Solution 1:

In RHEL you have /etc/sysconfig folder. Here you define startup parameters. And in your startup script you include something like:

if [ -f /etc/sysconfig/$prog ] ; then
    . /etc/sysconfig/$prog
fi

Check existing services for examples.

For development you can put your startup parameters in an exported variable (for example in .bashrc) which you can manually override any time you wish.

EDIT

If you really want to use service there are some other options.

Your script should support at least start and stop. But you can also implement a debug command. And start your program with:

service foo debug

Another way will be to check for the second argument in your script and you start your program with:

service foo start debug

Modify your init script to something like:

case "$1" in
  start)
        if [ "$2" = "debug" ]
        then
                start_debug
        else
                start
        fi
        ;;

Solution 2:

In Ubuntu, startup parameters are typically found in:

/etc/default/<service_name>

Tags:

Service

Redhat