how to start/run a windows service at particular time (say: 12:00 PM) every day? - windows-services

Background: I have developed a windows service which runs once every day and does the work (every thing is just right!)
Issue: the service runs exactly at the same time (last run time) the other day..
Ex: If I start the service at 4:00 PM today so it will run again at 4:00 PM every day.
My solution till yet (but not working fine) I want it to configure it self with the StartTime and IntervalTime mentioned in the app.config file and run at that time everyday (regardless of when I have started it)
Having problems with this silly thing .. Please help in this regards with sample code.
Your help is really appreciated, Thanks in advance.
For further clarification, if I have mentioned in app.config
key="StartTime" value="12:00"
key="Interval" value="86400000"
so it must run on 12:00 PM every day (as interval period is 86400000 milliseconds i.e. 1day) regardless of the time when I started it or make it live.

You could set up a scheduled task that starts the service at a specific time and stops it at another via a batch file. You would utilize the commands net stop myservice and net start myservice in the batch file.

Related

Is there a way to lock down deployments to only be during a specific time of day?

I want to be able to only deploy anytime between 9:00am and 6:00pm on certain days. I already have the builds locked down by day using "Set approvedDays" but I need one for hours.
Maybe this Jenkins plugin could solve your problem: https://github.com/jenkinsci/working-hours-plugin

Run job once at 8 PM and stop at 6 AM in Quartz.net

How can i schedule job to run once at 8:00 PM Every Day and force it to stop at 6:00 AM in next day?
Setup trigger to run job every day at 8PM. If you prefer cron expressions, you can use cronmaker UI for expression generation.
As #derloopkat mentioned, Configuring Quartz.Net to stop a job from executing, if it is taking longer than specified time span shows approach how to stop job using IInterruptableJob interface. Moreover, cause you know exact time, when job should be stoped (6AM), you may not to use separate thread for Interrupt() method, but create another simple job that do interruption at 6AM by trigger.

Time-Driven Trigger to run every X minutes during a given time period?

I have a script that I have to run every 10 minutes but only during say 1AM - 2AM Local time.
Long story short; the script updates about 80+ internal Google Spreadsheets but it must only do this during the hours mentioned above so the chance of a user being in a spreadsheet doing work at the time is almost zero.
I've looked at the Time-Driven Triggers and it has both the functions (to run every 10 minutes and also to run between 1am-2am) however I need to fuse these two triggers together.
Is this possible?

Managing timezones for different users

I have a website where I have many users coming from different countries. Users can schedule a task based on their timezone. Now there is a cron running on the server after every min, the cron executes a script which checks if there are any scheduled task of any user and if so it does the needful.
Since my server is based in the US, the script executed by the cron considers the timezone of the US. What do I have to do in my script that will execute the user's task based on user's timezone instead of server's timezone?
Thanks in advance for any ideas
Lookup the user's timezone.
Compute the current time in the user's timezone.
For each job, look up the last time it was run and compute the next time it should run.
For any job whose next run time is now or in the past, run that job and update the record of the last time each job was run.
I did something similar on the iPhone a few months ago.
My solution was to capture the time as a string. So if the user selected 8am, I would just capture 08:00 and their time zone e.g. Europe/London.
Every 5 minutes or so on my server, I could then convert this 08:00 into the current UTC time based on the timezone. If this time was "present", I would carry about a check on the user's transport status and issue alerts.
To help me with the TimeZones, I used NodaTime. http://noda-time.blogspot.co.uk/

How to run a scheduled task at specific times?

I need to run a scheduled task every day at 9 a.m. and 6 p.m. How can I do this? I looked into PeriodicTask but it runs once every 30 mins. How do I achieve this task?
You can't. However, you can check if the time is close to 9am/6pm when the Scheduled Task is running every 30 minutes. The furthest off you'll get is 29 minutes.
Consider using a Reminder instead.
you can use the scheduled notification of Alarm in windows phone os7.1.
check here:http://msdn.microsoft.com/en-us/library/hh202946(v=VS.92).aspx

Resources