Thanks a lot spjackson, no I didn't know that . I have now read up about cronjobs using crontab and appreciate sanderj's method. So basically, every minute we are doing a chmod +x to my shell scripts under that folder. Cool!
I just have one final question(/need confirmation really) regarding scheduling cronjobs. So since cronjobs are of this format
MIN HOUR DOM MON DOW CMD, just wanted to confirm that no one writes a cronjob with both the DOM(day of month) and DOW(day of week) both filled in right, it wouldn't make any sense if they were not consistent with each other ?(Assume June19 is a Wednesday and along with filling this, you also fill a Thursday(4) to the DOW column.
Something like * * 19 6 4 /execute-my-script.sh.
Just confirming.
Thanks a lot for the other replies too, I truly appreciate.
Note that executing "chmod +x ..." on all the files each time resets their "change date" so they will be picked up by backup managers each time. You may want to change the flag only on files where it is not set yet (see the various filtering options of the "find" command.
It depends what you mean by "make any sense", and precisely what you are trying to do. If you schedule a job for Sunday 1 January, then it won't happen next year, or in 2015 or 2016, but it will in 2017. If for some reason that was your intent, then that would be a way to express it.
So when you say "Assume June19 is a Wednesday...", well some years it is and some years it isn't.
Using this kind of combination is probably unusual but that doesn't make it nonsensical or pointless.
Last edited by spjackson; June 19th, 2013 at 01:02 PM.
thanks spjackson, I didn't think about that. so basically 30 1 19 6 2 will execute at 1:30 on 19th June only in a year when it is a Tuesday.
So we represent this as a logical condition as follows
Thanks for clearing this. If not this year, but some year didn't strike me at all.Code:/* assume format : MIN HOUR DAYOFMONTH MONTHNO DAYOFWEEK script.sh */ if(currentmin==MIN && currenthour==HOUR && currentdayofmonth==DAYOFMONTH && currentmonth==MONTHNO && currentdayofweek==DAYOFWEEK) { system("./script.sh"); }
Last edited by IAMTubby; June 19th, 2013 at 02:29 PM.
Like I said...Originally Posted by crontab(5)
Eh, understandable. I think that's the only exception.
Bookmarks