-   Linux - Software (
-   -   Daemon question (

Alex90 07-24-2015 08:40 AM

Daemon question

Hello guys

Today I create a daemon on ubuntu called "daemonprova"

When i execute it , i can see that it work , throught "ps aux" command that output the process of my system.

and i can see it


alex      2839  0.0  0.0  2160  292 ?        Ss  15:38  0:00 ./daemonprova

alex      2841  0.0  0.0  4696  820 pts/0    S+  15:38  0:00 grep --color=auto daemonprova

But, when i digit "sudo service daemonprova status"

The terminal say me "daemonprova: unrecognized service"

Why my system don't recognized daemonprova if I executed it?

rtmistler 07-24-2015 09:45 AM

Firstly, please review this link to assist you with better ways to form your question.

On the subject of the daemon, it appears that you have compiled a program intended to be a daemon and then run it. I say this given the appearance that it is showing:

Therefore, is it true that you ran it from a command line? If so, while it may be a daemon, it is not recognized as a service yet to your system because you have not added it as a service.

Please let me know if my guess about how you ran the program is the case and I'll let you know how to establish it as a service so that you can query it in that manner.

- RT

michaelk 07-24-2015 10:08 AM

What version of Ubuntu are your running?

Per the service man page... "The purpose is to run an initialization script in as predictable environment as possible, removing most environment variables and with current working directory set to /." The initialization scripts are located in the /etc/init.d directory and have a particular format.

Alex90 07-24-2015 10:25 AM


For become my process a service i follow these steps

1) save your program that will run as a service in /usr/sbin
sudo cp myprogramname /usr/sbin/myscriptname

2)create a basic startup script (use /etc/init.d/skeleton as reference)

3)move this script to /etc/init.d
sudo mv /etc/init.d/myscriptname

4)give this script executable permission (i used 775, but you can set it lower)
sudo chmod 755 /etc/init.d/myscriptname

5)goto /etc/init.d
cd /etc/init.d

6)include in startup list with low startup priority
sudo update-rc.d myscriptname default

7)reboot your machine and check if the service has started properly
sudo ps -A --sort cmd or service --status-all

michaelk 07-24-2015 11:02 AM

To mark your thread as solved use the thread tools pull down menu at the top.

All times are GMT -5. The time now is 11:54 PM.