LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-24-2015, 08:40 AM   #1
Alex90
LQ Newbie
 
Registered: Jul 2015
Posts: 20

Rep: Reputation: Disabled
Daemon question


[SOLVED]

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

Code:
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?

Last edited by Alex90; 07-24-2015 at 10:23 AM.
 
Old 07-24-2015, 09:45 AM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,813
Blog Entries: 13

Rep: Reputation: 4875Reputation: 4875Reputation: 4875Reputation: 4875Reputation: 4875Reputation: 4875Reputation: 4875Reputation: 4875Reputation: 4875Reputation: 4875Reputation: 4875
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:
Code:
./daemonprova
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
 
Old 07-24-2015, 10:08 AM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 24,720

Rep: Reputation: 5593Reputation: 5593Reputation: 5593Reputation: 5593Reputation: 5593Reputation: 5593Reputation: 5593Reputation: 5593Reputation: 5593Reputation: 5593Reputation: 5593
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.

http://www.cyberciti.biz/tips/linux-...p-service.html
 
Old 07-24-2015, 10:25 AM   #4
Alex90
LQ Newbie
 
Registered: Jul 2015
Posts: 20

Original Poster
Rep: Reputation: Disabled
SOLVED!

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
 
Old 07-24-2015, 11:02 AM   #5
michaelk
Moderator
 
Registered: Aug 2002
Posts: 24,720

Rep: Reputation: 5593Reputation: 5593Reputation: 5593Reputation: 5593Reputation: 5593Reputation: 5593Reputation: 5593Reputation: 5593Reputation: 5593Reputation: 5593Reputation: 5593
To mark your thread as solved use the thread tools pull down menu at the top.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Daemon user question g_paschoal Linux - Server 13 02-01-2012 05:21 AM
How-To Write a Linux Daemon (a question) animehair Linux - Software 5 04-10-2006 10:46 AM
smbd (samba) daemon startup question GetCool Debian 3 11-16-2003 03:22 PM
Network Daemon Question ? chamkila Linux - General 3 01-20-2003 03:10 PM
Question : Possible to change Daemon Names During Start Up? Kaj Linux - General 1 05-29-2001 02:15 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration