Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to execute code in c# service one time per day at the same hour?

So here's my problem, I need to do a c# service running on a server who's getting file on ftp one time per day at 3am. I think that I can do it with a thread.sleep() or by compare the DateTime.Now with 3am....

Do you have better solution?

Thank you very much for your help!

like image 622
Bigballs Avatar asked Sep 03 '09 13:09

Bigballs


People also ask

How do I compile in C?

Compilation process in C involves four steps: pre-processing, compiling, assembling, and linking. The preprocessor tool helps in comments removal, macros expansion, file inclusion, and conditional compilation. These commands are executed in the first step of the compilation process.

What is execution file in C?

An executable file (EXE file) is a computer file that contains an encoded sequence of instructions that the system can execute directly when the user clicks the file icon. Executable files commonly have an EXE file extension, but there are hundreds of other executable file formats.

Which command is used to execute the C program?

Answer. Step0: Install C-Program Compiler (gcc) You will need a C compiler to do this already installed, I use GCC. If you are on a Windows computer, you can run the command gcc -v to check if it's already installed.


2 Answers

Write a console app or equivalent, and use the Windows Scheduler (or whatever it's called nowadays...) to run it daily.

like image 66
Tomas Aschan Avatar answered Oct 05 '22 16:10

Tomas Aschan


I've used Scheduled Tasks successfully for backups, but I have a word of caution ...

Scheduled tasks are not be performed if you log out. I'm not sure if this can be overidden, but I have been caught out by tasks not performed because Windows automatically updates, reboots and sits waiting for me to log-in.

I disabled automatic updates - Windows should ASK first.

Another consideration is that 3AM is a time when many users would normally be logged out.

like image 30
pavium Avatar answered Oct 05 '22 18:10

pavium