Page 3 of 3 FirstFirst 123
Results 21 to 30 of 30

Thread: want all files in a particular folder to have permission 755

  1. #21
    Join Date
    Mar 2006
    Beans
    393

    Re: want all files in a particular folder to have permission 755

    Quote Originally Posted by IAMTubby View Post
    Hello,
    Assume I have a folder called /home/IAMTubby/shellscrtipts .I want all files created in this folder to have permission 755.

    Use case:
    Otherwise, for every shell script I write, before running, it , I have to go and do a chmod +x myshellscript.sh or sh myshellscript.sh.

    Thanks.
    See:
    man find
    man chmod
    Just my 0.00000002 million dollars worth,
    Shawn

    Programming is as much about organization and communication as it is about coding.

  2. #22
    Join Date
    Aug 2012
    Beans
    623

    Re: want all files in a particular folder to have permission 755

    Quote Originally Posted by spjackson View Post
    The one you have scheduled (with * in every field) runs once each minute.
    Quote Originally Posted by sanderj View Post
    Put in a crontab entry * * * * *, and ... problem solved.
    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.

  3. #23
    Join Date
    Aug 2011
    Location
    47°9′S 126°43W
    Beans
    2,172
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: want all files in a particular folder to have permission 755

    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.

  4. #24
    Join Date
    Feb 2009
    Beans
    1,469

    Re: want all files in a particular folder to have permission 755

    Quote Originally Posted by IAMTubby View Post
    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 ?
    Code:
    $ man 5 crontab

  5. #25
    Join Date
    Aug 2010
    Location
    Lancs, United Kingdom
    Beans
    1,588
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    Re: want all files in a particular folder to have permission 755

    Quote Originally Posted by IAMTubby View Post
    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 ?
    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.

  6. #26
    Join Date
    Aug 2012
    Beans
    623

    Re: want all files in a particular folder to have permission 755

    Quote Originally Posted by spjackson View Post
    "Assume June19 is a Wednesday...", well some years it is and some years it isn't.
    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
    Code:
    /* assume format : MIN HOUR DAYOFMONTH MONTHNO DAYOFWEEK script.sh */
    if(currentmin==MIN && currenthour==HOUR && currentdayofmonth==DAYOFMONTH && currentmonth==MONTHNO && currentdayofweek==DAYOFWEEK)
    {
     system("./script.sh");
    }
    Thanks for clearing this. If not this year, but some year didn't strike me at all.
    Last edited by IAMTubby; June 19th, 2013 at 02:29 PM.

  7. #27
    Join Date
    Feb 2009
    Beans
    1,469

    Re: want all files in a particular folder to have permission 755

    Quote Originally Posted by crontab(5)
    Note: The day of a command's execution can be specified in the follow‐
    ing two fields — 'day of month', and 'day of week'. If both fields are
    restricted (i.e., do not contain the "*" character), the command will
    be run when either field matches the current time. For example,
    "30 4 1,15 * 5" would cause a command to be run at 4:30 am on the 1st
    and 15th of each month, plus every Friday.
    Like I said...

  8. #28
    Join Date
    Aug 2010
    Location
    Lancs, United Kingdom
    Beans
    1,588
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    Re: want all files in a particular folder to have permission 755

    Quote Originally Posted by trent.josephsen View Post
    Like I said...
    Indeed. My mistake. Apologies. I have long held the mistaken impression that all fields are ANDed, Clearly not.

  9. #29
    Join Date
    Feb 2009
    Beans
    1,469

    Re: want all files in a particular folder to have permission 755

    Eh, understandable. I think that's the only exception.

  10. #30
    Join Date
    Aug 2012
    Beans
    623

    Re: want all files in a particular folder to have permission 755

    Quote Originally Posted by trent.josephsen View Post
    Like I said...
    Thanks a lot trent.josephsen.

Page 3 of 3 FirstFirst 123

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •