Schedule timer to be executed once a month - C#

后端 未结 2 591
故里飘歌
故里飘歌 2021-01-29 01:42

I need to transfer some data from SQL Server to MySQL, once a month. I have already done this transfer stuff, but I don\'t know (and I have not found out on the internet) how to

相关标签:
2条回答
  • 2021-01-29 02:00

    This sounds like something you should set-up as a scheduled task or a SQL server job rather than having a process run for a month via a timer?

    Links:

    • SQL Server job in 2008
    • Schedule windows task

    I guess you could also setup a task as a windows service and check the last time you did the update via a setting in the database, but that seems like overkill. From the sound of it you already have a C# app setup that does the job, so I would just make a scheduled windows task.

    0 讨论(0)
  • 2021-01-29 02:04

    You could use the Windows Task Scheduler for this kind of work. Look here for command line options of Schtasks (there's tons of them)

    Example 1:

    To schedule a task that runs on the first day of every month

    The following command schedules the MyApp program to run on the first day of every month. Because a value of 1 is the default for both the /mo (modifier) parameter and the /d (day) parameter, these parameters are omitted from the command.

    schtasks /create /tn "My App" /tr myapp.exe /sc monthly
    

    Example 2:

    To schedule a task for the 15th day

    The following command schedules the MyApp program to run on 15th of every month at 3:00 P.M. (15:00). It uses the /d parameter to specify the date. It also uses the /st parameter to specify the start time.

    schtasks /create /tn "My App" /tr myapp.exe /sc monthly /d 15 /st 15:00
    
    0 讨论(0)
提交回复
热议问题