Karp 的技术博客

最近有个问题困扰我.
crontab 执行脚本生成文件都是root 用户.
web 写文件 apache 用户 造成apacheroot 同时写一份日志 apache 权限不足!!
解决方案 :


vim /etc/crontab 
*  *  *  *  * user-name command to be executed
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# For details see man 4 crontabs

# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name command to be executed

#OTC每分钟检测订单更新订单状态
*/1 * * * *  apache /usr/bin/php /home/index.php Crontab autoUpdateOrderStatusCrontab >> /tmp/autoUpdateOrderStatusCrontab.log 2>&1

crontab

版权属于:karp
作品采用:本作品采用 知识共享署名-相同方式共享 4.0 国际许可协议 进行许可。
更新于: 2018年03月02日 13:55
9

目录

来自 《Crontab 指定执行用户》