添加Windows exe文件作为ubuntu服务 [英] Add a Windows exe file as ubuntu service

查看:84
本文介绍了添加Windows exe文件作为ubuntu服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

那里



我用C#创建了一个名为filewatcher.exe的Windows服务文件,并通过InstallUtil.exe将此服务安装到Windows服务器。我想在Ubuntu中添加相同的文件作为服务(跨平台服务)。所以我在我的ubuntu中安装了mono并使用命令

Hi, there

I created an windows service file named filewatcher.exe by C# and installed this service to windows server via InstallUtil.exe. I want to add the same file as a service in Ubuntu(cross-platform service).So I've installed mono in my ubuntu and use the command

sudo update-rc.d filewatcher.exe defaults



是的,filewatcher.exe已添加为服务并已启动。但它不起作用。



如何使服务工作或我该怎么做才能使服务在Windows和Linux中都能正常工作?



谢谢


yes, the filewatcher.exe has been added as a service and started. But it doesn't work.

How can I make the service work OR what should I do to make the service work in both windows and linux?

Thanks

推荐答案

尝试提供程序的完整路径:

Try supplying the full path to your program:
sudo update-rc.d /fullpath/here/for/example/filewatcher.exe defaults


好吧,从这个问题来看,我有得到三点:

1,filewatcher.exe是由VS2012开发的--Windows服务(C#)项目,这种.exe不能在Ubuntu上运行单声道,也许windows服务的特殊配置只能是安装为Windows服务。但是,正常的C#可执行文件(例如:Windows Forms Application的exe文件)可以在Ubuntu上由mono运行。

2,虽然单声道运行时不能设置为filewatcher.exe的默认应用程序,但我们可以使用

Well, from this question, I have got three points:
1, filewatcher.exe is developed by VS2012 - Windows Service(C#) project, this kind of .exe cannot be run by mono on Ubuntu, maybe windows service's special configuration can only be install as windows service. However, normal C# executable file (e.g: Windows Forms Application's exe file) can be run by mono on Ubuntu.
2, Although mono runtime cannot be set as the default application for filewatcher.exe, we can use
mono filewatcher.exe



来运行它。

所以,我们可以创建一个这样的脚本 - 假设脚本文件名是filewatcherservice:


to run it.
So, we can create a script like this - assume the script file name is filewatcherservice:

#! /bin/bash
mono /home/user/filewatcher.exe



然后,使用以下命令:


and then, use the following command:

sudo chmod +x filewatcherservice



使其成为可执行文件然后将此文件复制到/etc/init.d目录

最后,将filewatcherservice作为服务安装


to make it an executable file
then, copy this file to /etc/init.d directory
finally,install the filewatcherservice as a service

sudo update-rc.d filewatcherservice defaults



3,使用以下命令(可能需要在使用之前安装它)


3, Use the following command(maybe you need to install it before use it)

sudo sysv-rc-conf



启动服务。

完成!



感谢大家的帮助。


to start the service.
Done!

Thanks everybody for your help.

这篇关于添加Windows exe文件作为ubuntu服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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