我在 root 下运行的 crontab 作业很少,但这给我带来了一些问题.例如,在该 cron 作业过程中创建的所有文件夹都在用户 root 和组 root 下.我怎样才能让它在用户 www-data 和组 www-data 下运行,以便当我从我的网站运行脚本时,我可以操作这些文件夹和文件?
I have few crontab jobs that run under root, but that gives me some problems. For example all folders created in process of that cron job are under user root and group root. How can i make it to run under user www-data and group www-data so when i run scripts from my website i can manipulate those folders and files?
我的服务器在 Ubuntu 上运行.当前的 crontab 工作是:
My server runs on Ubuntu. Current crontab job is:
*/1 * * * * php5 /var/www/web/includes/crontab/queue_process.php >> /var/www/web/includes/crontab/queue.log 2>&1 推荐答案不是创建以 root 用户身份运行的 crontab,而是为要运行脚本的用户创建一个 crontab.在您的情况下, crontab -u www-data -e 将为 www-data 用户编辑 crontab.只需将您的完整命令放在那里,然后从 root 用户的 crontab 中删除它.
Instead of creating a crontab to run as the root user, create a crontab for the user that you want to run the script. In your case, crontab -u www-data -e will edit the crontab for the www-data user. Just put your full command in there and remove it from the root user's crontab.
更多推荐
如何在 crontab 中指定哪个用户运行脚本?
发布评论