PLEASE NOTE: the upgrades to this server, secure.csse.uwa.edu.au, have not yet been completed.
Hopefully the changes will be completed on THURSDAY 8th December.
Web-based programs, such as csmarks, cssubmit, and the help fora, will be unavailable at some time on Thursday 8th.
  It's UWAweek 49

help2002

This forum is provided to promote discussion amongst students enrolled in CITS2002 Systems Programming.
Please consider offering answers and suggestions to help other students! And if you fix a problem by following a suggestion here, it would be great if other interested students could see a short "Great, fixed it!"  followup message.

Displaying the 4 articles in this topic
Showing 4 of 919 articles.
Currently 4 other people reading this forum.


 UWA week 37 (2nd semester, week 7) ↓
SVG not supported

Login to reply

👍?
helpful

Hello friends I have been stuck for a while now on conceptualising a logical flow for simulating the running of the crontab processes. My plan was to have a while loop to iterate through every single minute in the target month, updating the counts of starting/running/terminating processes at the end of every iteration of the loop. Something like, while(is_current_month){ print(current_minute); current_minute++; } However, I am stuck as to how to progress from here. I'm not asking for help with the C language, rather some architectural tips on how to logically step out the process of start, duration, and end of a process within this loop. Do I iterate through every single line in crontab-file, testing if the minute and hour are equal to the current minute and hour? Or if the crontab hour is a "*" and the current minute is 0? etc. This doesn't seem efficient, there would have to be a dozen "if-or-or-or" statements to account for the multiple different combinations of "*" characters and integer entries that could lead to the current minute being a valid time for a process to be started. Apologies for the wall of text, I am sure I'm missing something obvious since no one else has asked this yet. Thanks


SVG not supported

Login to reply

👍?
helpful

ANONYMOUS wrote:
> Do I iterate through every single line in crontab-file, testing if the minute and hour are equal to the current minute and hour? Or if the crontab hour is a "*" and the current minute is 0? etc. This doesn't seem efficient, there would have to be a dozen "if-or-or-or" statements to account for the multiple different combinations of "*" characters and integer entries that could lead to the current minute being a valid time for a process to be started.
That's about the simplest approach - iterate through each of the 40K+ minutes of the month, checking to see if any of the crontab entries match the current time/date. Do not worry about efficiency for your first 'attempt' - in fact don't worry about efficiency at all (unless your execution time is horrendous). Your desktop or laptop computer can perform at least 1 BILLION comparisons per second, so it's unlikely you'll even be able to develop a slow solution!


SVG not supported

Login to reply

👍x3
helpful

I have the same question and am stuck on this, too. If we loop over the entire month in minutes, how would we know at what time the command should be executed? Let's say: "0 3 * * * say_hello", would we 'execute' at the 180th minute? How is it possible to calculate the timing in minutes for every crontab file? How would we 'execute' these commands? I apologise about the numerous questions. In slight dire need of help.


SVG not supported

Login to reply

👍?
helpful

ANONYMOUS wrote:
> I have the same question and am stuck on this, too. If we loop over the entire month in minutes, how would we know at what time the command should be executed? Let's say: "0 3 * * * say_hello", would we 'execute' at the 180th minute? How is it possible to calculate the timing in minutes for every crontab file? How would we 'execute' these commands? I apologise about the numerous questions. In slight dire need of help.
If you're iterating from the first minute (starting at 12:00 midnight on the first day of the requested month) to the last minute (44K+ of them) you need to *match* the current minute against the 'pattern' of 5 numbers "0 3 * * *". If they *match* (yes, 180 minutes does match, as does 180 minutes + 24 hours), then the named command begins at those times, and executes for the number of minutes given in the 'estimates' file. At 180 minutes, the mins=0 matches, the hours=3 matches, the dayofmonth=* matches, the month=* matches, and the weekday=* matches, so the command will start. The matching does get harder when we need to match specific (valid) days of the week, so review the Workshop where we examined dealing with days, months, and weekdays.

The University of Western Australia

Computer Science and Software Engineering

CRICOS Code: 00126G
Written by [email protected]
Powered by history
Feedback always welcome - it makes our software better!
Last modified  1:17AM Sep 14 2022
Privacy policy