Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run C# .exe with crontab or daemon?

I was wondering if i can run a dll (c#) with crontab ? The dll is compile with mono.

thx :)

-- EDIT --

Well it can be a .exe. I was looking at daemons on mac and linux, do you think I can run .exe as a daemon.

like image 683
David Fortin Avatar asked Mar 08 '11 17:03

David Fortin


2 Answers

Why not write a mono-based exe that takes the DLL path and entry point method as parameters? The exe would then use reflection to load the DLL and execute the specified method. (You could opt for convention-over-configuration by specifying something like a DllMain method in your DLL which the exe would know to call automatically. Then just one parameter would be required and the intent of your code more obvious.)

Implementing such an applet would give you a utility similar to RunDll in Windows and allow you to run mono DLLs from cron.

like image 66
Paul Sasik Avatar answered Sep 22 '22 02:09

Paul Sasik


You may want to check out the latest mono release and C# Shell (although I would personally make an exe that called the functions you want from the DLL).

http://www.mono-project.com/CsharpRepl

"On startup the csharp shell will load any C# script files and pre-compiled libraries (ending with .dll) that are located in the ~/.config/csharp directory (on Windows this is the value of Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData)).

The assemblies are loaded first, and then the scripts are executed. This allows your scripts to depend on the code defined in the assemblies.

C# script files are merely files that contains statements and expressions, they can not contain full class definitions, those should be stored and precompiled in DLL files. "

Then you can do things like:

 csharp> using System;   
 csharp> Console.WriteLine ("hello");    
 hello   
 csharp>   
like image 34
sclarson Avatar answered Sep 21 '22 02:09

sclarson