CRON for File Permissions

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Frank Hagan
    Senior Member
    • Mar 2004
    • 724

    #1

    CRON for File Permissions

    I have a photo posting script that sometimes does not give the right permissions to photos, and they cannot be seen. The fix is easy enough; I go in and change the permissions to 644, and all is well. But it takes manual intervention.

    I'm wondering if there's a way to make a cron job that I run weekly to change the file permissions of all files in a specific directory to rw-r--r-- I'm just not sure of the syntax that would take ... something like "chmod rw-r--r-- home/public_html/directory/*.*" perhaps?
  • Amitabh
    Member
    • Mar 2004
    • 78

    #2
    Would be better if you pass in the complete path:
    Code:
    /bin/chmod -R 644 /home/<insert_user_name>/public_html/<directory_name>
    or for a single file

    Code:
    /bin/chmod 644 /home/<insert_user_name>/public_html/<directory_name>/<file_name>

    Comment

    • Frank Hagan
      Senior Member
      • Mar 2004
      • 724

      #3
      I logged into a ssh session using Putty, and tried using:

      /bin/chmod -R 644 /home/<myusername>/public_html/<directory>

      to test the syntax out. While it lists all the files, it gives a "permission denied" message on each one, so it doesn't change the permissions. Not sure why this is happening; I know the username is correct, as I'm logged in under it.

      Comment

      • Frank Hagan
        Senior Member
        • Mar 2004
        • 724

        #4
        Anyone know why this won't work from a SSH login?

        Code:
        /bin/chmod -R 644 /home/<insert_user_name>/public_html/<directory_name>
        I don't want to set up a cron job with something I haven't verfied (been there, done that, learned what "suspended" means when the script went berserk!)

        Am I missing /usr/ in front or something?

        Comment

        • AndrewT
          Administrator
          • Mar 2004
          • 3656

          #5
          Is it reporting an error or anything? That should work just fine.

          Comment

          • Frank Hagan
            Senior Member
            • Mar 2004
            • 724

            #6
            Yep, its giving me a "failed to get attributes of" message, lists the file in the directory, and then has a "permission denied" message. It lists each of the files in the directory, so I know its finding them.

            Comment

            • AndrewT
              Administrator
              • Mar 2004
              • 3656

              #7
              Submit a trouble ticket with the exact command you are trying to run along with your SSH user/pass.

              Comment

              • Frank Hagan
                Senior Member
                • Mar 2004
                • 724

                #8
                As usual, the problem was quickly solved with a trouble ticket. Actually, the easy part was. My command string should have had an asterik on the end of it:

                Code:
                NOT:
                /bin/chmod -R 644 /home/<insert_user_name>/public_html/<directory_name>
                
                But this format:
                /bin/chmod -R 644 /home/<insert_user_name>/public_html/<directory_name>/*
                The command still has trouble because of the number of files in the directory. I'll have to look at the script and see if I can move some of the files without manually editing the 2000 image paths!

                The script I'm using is Photopost, and it has to be the worst script, especially since I paid the most for it, and the authors are less than helpful. I would love it if I could convert the pics to Goldmine. I may have to do that manually.

                Comment

                Working...