Making Files Readonly With a script

Ask a Question related to Linux Setup, Configuration & Administration, Design and Development.

  1. #1

    Default Re: Making Files Readonly With a script

    On Tue, 26 Aug 2003 21:50:02 +0100, JRH <john.nntp@yoredale2003.uklinux.net> wrote:
    >
    >
    > Brad S wrote:
    >
    >> My goal is to make all files in my usershare directory readonly if the
    >> have not been modified within the last 14 days. I am assuming that I
    >> could do this with cron, can anyone help me with the commands that I
    >> would be using? I have a feeling that the find command will be used,
    >> but I am still just a newbie admin.
    >
    > First create a script that does what you want...
    > man find
    > man chmod
    > will provide the info you need to know.
    > Also look at bashref.html for help on writing scripts. It is probably part
    > of your distro.
    >
    > To run via cron, Red Hat and Mandrake (and others probably) have a
    > /etc/cron.daily directory. Put your script in there. Much easier than
    > messing with crontab. And that way it gets processed by anacron if the
    > system is down at the time it should have run. But if you want to be more
    > adventurous, try
    > man cron
    > man crontab
    > man anacron
    >
    > ...John

    For the cron.daily script, make sure you use full paths for EVERYTHING.

    This should work:


    #!/bin/bash

    /usr/bin/find yourdir -mtime +14 -exec /bin/chmod 444 {} \;

    exit 0


    Alan C

    --

    take control of your mailbox ----- elrav1 ----- [url]http://tinyurl.com/l55a[/url]
    Alan Connor Guest

  2. Similar Questions and Discussions

    1. Script Error after making changes
      First, I am not a website designer. I own a website and have been making minor (text) changes using Contribute since I didn't need to know html. I...
    2. PDF-making Script
      Is there a script to get pdfs made automatically? Currently, I am making pdfs by processing ad after ad by making a ps file and then dragging it into...
    3. Files not showing readonly or checked out
      I connected to my remote folder on my web server and synchronized the local view with the remote view. this worked fine. The problem is that the...
    4. Files become ReadOnly
      Hello For some strange reasons, some of my files become ReadOnly when I copy them to a subfolder to my ASP.NET application. For each new session I...
    5. making pdf files from prn files - fonts error
      PLS help! Operating system - XP Adobe version - 4.05, 5 and 6... (tried them all) ever since I upgraded my operating system to XP I experience...
  3. #2

    Default Re: Making Files Readonly With a script

    > For the cron.daily script, make sure you use full paths for EVERYTHING.
    >
    > This should work:
    >
    >
    > #!/bin/bash
    >
    > /usr/bin/find yourdir -mtime +14 -exec /bin/chmod 444 {} \;
    I'd add a -type f, or directories will be left inaccessible.

    Eric
    Eric Moors Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139