0

I have a directory on the server - var/www/html/content - and I would to give everything inside this directory, recursively, 755 permissions (or maybe 757, that's not really important at this point) at exactly 9:30am every day.

I thought the best way to do this would be to create a .php file that contains something like;

$ chmod -R 757 var/www/html/content/

I'm guessing I'd need an su command in there to switch to root as well???

Then all I would need to do is set up a cron job through the command line. Something like;

30 09 * * * /var/www/html/run-job.php

Is this about right? Is there a better way to do this kind of task? I've never done anything like this before...

EDIT

I've been asked to add some more context...

Basically, the "content" directory essentially holds a library of PDF, Excel and HTML files. Different PDFs on different topics going out routinely, about once a week, but they have to be released at 9:30am on a specific day.

If i set this cron job up correctly then I can upload the files the day before (sometime in the afternoon) and I don't have to worry about being in at 9:30 the next day to do it manually.

All I would need to do is move the files over, change the permissions to 000 (or something so the public or apache can't view it) and then at 9:30 on the day my script can make all of it visible for me whilst I'm at home sleeping.

Make sense?

4

1 回答 1

1

You can run commands directly from cron, so you can achieve it, by putting to cron:

30 09 * * * /bin/chmod -R 757 /var/www/html/content/

You can edit cron jobs for current user, by entering:

crontab -e

You can see list of cron jobs for current user, by entering:

crontab -l
于 2013-08-13T09:58:36.453 回答