create a chmod cron job help please

hi all,

I'm so embarrasingly new; apologies.

So here's my dilemma; files are being uploaded to the server via a php script... this is therefore assigning ownership to 'nobody' rather than the account 'user'.
It's screwing with the permissions and then the owner can't ftp download images that were uploaded through this script.

So what I'm trying to do is create a cron job which will at 2am run through like 4 different folders within the user's account and chmod all of the images within the folder to 644.

Here's an example of what I was told to do:

You will want to use the following commands:

From secure shell as root, run the command:
crontab -e

Then setup a cron job to run hourly with the command 'chown -R $user:$group /home/$user/public_html/$directory' with the correct values for those variables.

  • end of example

My question is this... am I going to have to create a cron job for each of the four folders?

Also; in the example the guy said to have the - correct values for those variables...
So, what do I need to change in the command -
'chown -R $user:$group /home/$user/public_html/$directory'

anything with a $ ?

and if it is anything with a $ - what is the group?

thanks in advance for any assistance!

this might help you

Even if the owner is nobody, could you modify the PHP script to create the files world-readable? Then the owner (and anybody else who knows the path) can download them.

You can create four different crontab entries, or a single one pointing to an external file containing a moderately more complex script which loops over those directories. This is probably the more sustainable solution, as you can test it whenever you like, rather than wait for cron to kick in, or muck with the cron timing entries temporarily when you want to test.