开发者

cron job as a different user?

I need to call a script via curl in one of my cron jobs. The script needs write access to the web root. Apache doesn't have write acce开发者_开发问答ss to my web root. How can I execute the cron job as a different user? Thanks.


You can use group permissions.

Create a group that will have write access to that directory.

groupadd web

Add yourself and apache to the new web group

useradd -G apache web

Change the document root's ownership permissions to belong to the new web group

chown -R you:web /path/to/docroot

Set the docroot writable

chmod a+w /path/to/docroot


No matter how you go about this, you need an account (the more restricted, the better) that has write access to the web root. This seems obvious, I know. Next, log in as that user and create the cron job. If you have root:

$ su
# su -u thisotheruser
$ crontab -e

and create the cron job. A couple exits later, and you're all set.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜