Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 631
  • Last Modified:

Linux daemon

Hi Experts,

I need to create a linux daemon that start stop a service ( basically launch a shell script)).
I need to be able to communicate with it remotely.

I don't really need where to start ?

Also don't know in which langage to implement it (C/C++ or java) I can program in both ?

Any help and advice ?

Thanks,
0
bachra04
Asked:
bachra04
  • 10
  • 7
  • 4
  • +1
2 Solutions
 
for_yanCommented:
What do you mean by daemon?
Dio you need to strat a sellscript at some time?

Maybe cron job will be an option?
0
 
bachra04Author Commented:
To be honest I don't really care as long as it does the job i.e I can communicate with it remotely and tell it to start/stop the job
0
 
for_yanCommented:
Do you need that it runs at specific times?
What you mean by accessing remotely - you can probably telnet and do whatever you need
0
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
for_yanCommented:


If you type

man crontab

it will give you information about how to set up crontab file
In this filwe you specifiy the timimng and periodicity when your job has to be executed and the
shelscript which needs to be executed

then you just say

crontab crontab.file

and cron daemon will see to it that your
jobs are running at specified times

I use it all the time - it is very useful option

Let me know if you have questions
0
 
bachra04Author Commented:
I want to access it from java client remote application and call start / stop
0
 
for_yanCommented:
what you mean by remote application - can you elaborate?

adn do you want to start/stop it yourself by uyour command?
Then you probably don't need the daemon, as you'll be your own daemon :)
0
 
bachra04Author Commented:
Sorry may be the daemon is not the right word
but What I need is a process running on linux machine and I can communicate with it remotely
The process exposes : start /stop methods that I can call from another client application running on another machine
0
 
for_yanCommented:
I would recommedn to use RMI (Remote Method Invocation) for that purpose.

http://download.oracle.com/javase/tutorial/rmi/index.html

So you can run the RMI server on your host and run RMI cilient on you local machine and clien will call method on the server
and this method wwould initiate your java program on the sevrver

RMI server is very light weight and easy in setup



0
 
CEHJCommented:
Why don't you just ssh into the box and start/stop it whenever you want?
0
 
for_yanCommented:
That is waht I was suggestiing in the very beginning:

>What you mean by accessing remotely - you can probably telnet and do whatever you need
0
 
bachra04Author Commented:
For Two reasons:
-  don't like to give to the user full access rights.
- The client code is gine be executed from an eclipse plugin
0
 
for_yanCommented:
Well, then RMI should serve your purpose
0
 
bachra04Author Commented:
yes RMI can be good I just want to run it automatically on linux ( the equivalent of windows service)
0
 
for_yanCommented:
You can start your server together with the startup sequence - it will be waiting for requests - if that waht you mnean by running it automatically

As I guess you are going to run your client manually

0
 
bachra04Author Commented:
>> You can start your server together with the startup sequence
I need to do it from the installer that I give to a user to install it ,
Is there any reference or documentation on how to do that ?

Thanks
0
 
for_yanCommented:
The RMI server start is just two commands:

rmiregistry &

and

java startServer &

you can do it from any place

Read the tutorial above - it is reaklly very simple
- you juts write interface which methons the methods
and the server class

adn then run "rmic" - program comes with java - which
makes stub and skeleton and you
keep skeleton with the server class and stub
with the clien class.

Then youn start rmiregistry (also tools comes with java distribuition)
and start registry and server on the server side.

Then on the client side you lookup your object on the registrty - and get a handle on it
and then invole remote method on thta object - very simple serevr
0
 
CEHJCommented:
>>
For Two reasons:
-  don't like to give to the user full access rights.
- The client code is gine be executed from an eclipse plugin
>>

That's fair enough.

If i were doing this, i would integrate it with the normal daemon management of whatever Linux distro you're using. This would often be /etc/init.d See

man inittab

to determine that's the daemon management being used in your case

As far as the remoting is concerned, rmi is a possibility, although maybe overkill for this purpose. I might be inclined to use a simple TCP/IP approach
0
 
bachra04Author Commented:
Hi CEJH,

You mean I create a TCP/IP connection and send commands using some proprietary protocol ?

I prefer this idea over RMI (because of all the Overhead included when using RMI).

Is there any sample code or reference for creating a TCP IP connection under linux and sending back and forth
messages ?

Also security is a concern, should use TLS or ?? ( the client application should enter some kind of password to connect to the daemon)
0
 
parparovCommented:
0
 
CEHJCommented:
>>You mean I create a TCP/IP connection and send commands using some proprietary protocol ?

Yes. I would think the protocol could be very simple. Create an SSLServerSocket and you should be fine
0
 
for_yanCommented:

>because of all the Overhead included when using RMI

There is minimum overhead associated with RMI - and you don't need to deal with sockets
and all this stuff

Unfortunately, RMI is very much overlooked  -  it works nicely, much simpler to use that all this
web services hype, and is much more effective, and does not need any thirfd-party server to depend upon.

Once you use it - you'll love it and start using all the time you need remotte access.
0
 
CEHJCommented:
:)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 10
  • 7
  • 4
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now