Find the answer to your Linux question:
Results 1 to 4 of 4
Hi all I am trying to create a service for several applications. However, i always meet the problem with display. For instance, i wrote a script for xclock ( which ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jul 2008
    Posts
    3

    Problem with start deamon


    Hi all
    I am trying to create a service for several applications. However, i always meet the problem with display.
    For instance, i wrote a script for xclock ( which runs properly when using command line) and then put it in /etc/init.d/

    #!/bin/sh
    # chkconfig: 234 56 26
    # description: xclock service
    # xclock This shell script takes care of starting and stopping
    # the xclock
    #
    export DISPLAY=":0.0"
    echo $DISPLAY
    # Source function library
    . /etc/rc.d/init.d/functions

    # Do preliminary checks here, if any
    #### START of preliminary checks #########


    ##### END of preliminary checks #######


    # Handle manual control parameters like start, stop, status, restart, etc.

    case "$1" in
    start)
    # Start daemons.

    echo -n $"Starting xclock daemon: "
    echo
    daemon xclock
    echo
    ;;

    stop)
    # Stop daemons.
    echo -n $"Shutting down xclock: "
    killproc xclock
    echo

    # Do clean-up works here like removing pid files from /var/run, etc.
    ;;
    status)
    status xclock

    ;;
    restart)
    $0 stop
    $0 start
    ;;

    *)
    echo $"Usage: $0 {start|stop|status|restart}"
    exit 1
    esac

    exit 0


    After that, i add xclock to chkconfig
    # chkconfig --add xclock
    # chkconfig --level 2345 xclock on


    I tried to run xclock through script ad found everything ok
    # /etc/init.d/xclock start
    But when i run as a service:
    # service xclock start
    :0.0
    Starting xclock daemon:
    No protocol specified
    Error: Can't open display: :0.0
    [FAILED]



    When i set DISPLAY as "localhost:0.0". The message "No protocol specified" disappeared but the Error message still shown

    What are the problems i met, how can i fix them?

    Thanks

  2. #2
    Linux Enthusiast
    Join Date
    Aug 2006
    Location
    Portsmouth, UK
    Posts
    539
    Code:
    chkconfig: 234 56 26
    Your script will need to have the xserver running to work, the graphical (x) run level is 5, you've set it here to start in every other run level!!
    RHCE #100-015-395
    Please don't PM me with questions as no reply may offend, that's what the forums are for.

  3. #3
    Linux Enthusiast
    Join Date
    Aug 2006
    Location
    Portsmouth, UK
    Posts
    539
    Code:
    After that, i add xclock to chkconfig
    # chkconfig --add xclock
    # chkconfig --level 2345 xclock on
    Oops missed that bit But you should change it to 5 only in the script and manually though.

    I can't remember at which point X is actually up and operational, try making is start later:

    Code:
    chkconfig: 5 98 26
    98 is just before the "local" script
    RHCE #100-015-395
    Please don't PM me with questions as no reply may offend, that's what the forums are for.

  4. #4
    Just Joined!
    Join Date
    Jul 2008
    Posts
    3
    Hi
    Thanks for your help. However, i did as you suggested but it did not work. i don't know why the application can run when i call the script directly /etc/init.d/xclock start but it cannot when calling in service service xclock start.

Posting Permissions

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