doulin2947 2013-08-13 01:55
浏览 27
已采纳

cron job使目录可见

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?

  • 写回答

1条回答 默认 最新

  • dou760663 2013-08-13 01:58
    关注

    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
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部