Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Divide Task Into a Day 1

Status
Not open for further replies.

talon121

IS-IT--Management
Jan 23, 2003
22
US
How would I use a timer or function to calculate or divide a task into a day. ie. execute task x times per day.

 

I've found it easiest to create the program to run a task once when it is executed, then set up a Scheduled Task in Windows to execute the program, which can execute it at specified intervals.


I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
Do you have information on how to programatically add new Windows Scheduled Tasks ? and is it pretty limited by OS? ie. Vista / XP / Win 7 + support?

I would love to do similiar via coding if that's possible... It's hard to figure out the logic behind dividing time into a task.
 

You will get a lot better response if you state what you are trying to accomplish, what is your final goal. Not: ‘how do I do XYZ’, but 'what would be the best approach of accomplishing my task'.

So far your post(s) are very vague...

Have fun.

---- Andy
 
Thanks Andy,

This is the dillema I think, I am trying to execute a task x times per day via Code... I dont know if thats vague or if Im just explaining it wrong.

I have a threaded program, so each thread should execute a task x times per day and remember where it left off.

 

OK, this is just me playing a guessing game here because your explanation is still pretty vague to me.

Since you want to “execute task x times per day” “via Code” “and remember where it left off.” I would create a little table (Access, SQL Server, Oracle, even a text file) where you can keep any needed information about your tasks, and write a simple EXE (scheduled to run every hour, for example, suggested by jebenson) that looks at this table and preforms needed tasks. You can write into that table information like: which other EXE should be run (small exe’s that preform the individual tasks), and when (every hour, every day, once a month, etc. This would be a part of info you can keep in your table). You can keep other information, like the place where you stopped so your task would pick it up from that place when it would start again.

I have something similar – an EXE that starts at night around midnight and runs some Stored Procedures in certain order. All that information is kept in the data base: order of jobs to run, how often (every day, once a month, weekend, etc). I keep adding, deleting, modifying procedures mentioned in this table, but the EXE file has not been touched for years.


Have fun.

---- Andy
 
Thanks, that sounds like a plan..

However, I think I am more lost on how to divide or schedule a task (via code)... ie. Run x times per day. or loop and execute on a particular interval.. (maybe Im over thinkin)
 

My days (usually) have 24 hours, so if one task should run 4 times a day, it should run 24 / 4 = 6, every 6 hours. if other task should run 10 times, that’s 24 / 10 = 2.4, every 2 hours and (convert 0.4 * 60 =) 24 minutes.

Have fun.

---- Andy
 
Thanks, a friend also suggested to keep it small... I think I figured it out from the postings everyone has helped with:

my friend nick said:
Keep the numbers smaller. 60 sec * 60 min * 24 hours = 86,400 seconds per day. / 45 = 1,920 sec per event * 1000 = 1,920,000 milisecs per event
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top