在Linux中创建服务 [英] Create service in Linux

查看:78
本文介绍了在Linux中创建服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我使用mono创建了一个控制台应用程序,其中包含一个while(true)循环,该循环不断记录到文本文件.然后我从init.d的shell脚本中调用了该脚本.它工作正常并正确记录.但是系统需要更多时间才能登录.我该如何解决


我在Linux上搜索了mono服务,发现了mono-service2 ServiceName.exe等.我试图在控制台和Shell脚本等中调用它,但对我来说不起作用.最后,我创建了一个控制台应用程序,该控制台程序可以正常工作,但是却减慢了OS登录速度(大约15分钟).

我发现了
mono-service2 -l:service.lock --debug Program.exe
并在终端中运行以上命令.命令执行得很好,但是没有输出

我如何使用C#创建更好的守护程序

在此先感谢您的帮助....

Hi,

I created one console application using mono that contains one while(true) loop that continuously log to a text file. And I called from a shell script from init.d. It''s working fine and log correctly. But the system take more time to login. How I can solve this


I googled about mono service in Linux I found mono-service2 ServiceName.exe etc. I tried to call this in console and in shell script etc but that not worked to me. Finally I created one console application its working but it slow down the OS login (About 15 minutes)


I found
mono-service2 -l:service.lock --debug Program.exe
and run the above in terminal. the commands are exucuted well but no output

How I can create a better daemon using C#

Thanks in advance to your help....

推荐答案

当您仅使用
This seems a hard way to do things when you could just use the syslog[^] and associated functions. It is usually more efficient to use native C/C++ code under Unix/Linux for this type of activity.


阅读以下内容:

http://stackoverflow.com/questions/351971/using-mono-service-to-wrap-a-windows-service-on-linux [ http://stackoverflow.com/questions/186493/how-do-i- code-a-mono-daemon [ ^ ]

http://stackoverflow.com/questions/1221110/windows-like- services-development-in-linux-using-mono [ ^ ]
Read the following :

http://stackoverflow.com/questions/351971/using-mono-service-to-wrap-a-windows-service-on-linux[^]

http://stackoverflow.com/questions/186493/how-do-i-code-a-mono-daemon[^]

http://stackoverflow.com/questions/1221110/windows-like-services-development-in-linux-using-mono[^]


这篇关于在Linux中创建服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆