【运维】定时任务创建
一、任务创建
查看系统用户下的所有定时任务**
1 | crontab -l |
添加定时任务
1 | crontab -e |
按 i 进入编辑,添加一行
1 | * * * * * cd /www/wwwroot/你的项目目录 && php think 你的命令 >> /tmp/tp_task.log 2>&1 |
示例(每分钟执行一次):
1 | * * * * * cd /www/wwwroot/myproject && php think task:sync >> /tmp/tp_task.log 2>&1 |
你只需要改 2 个地方:
1 | /www/wwwroot/你的项目目录 |
1 | */5 * * * * |
二、定时任务维护
1.查看定时任务
1 | crontab -l |
2.查看定时任务日志
1 | tail -f /var/log/cron |
3.查看你命令的输出日志
1 | tail -f /tmp/tp_task.log |
4.查看执行用户,以下为www用户
1 | crontab -u www -l |
个人游戏开发
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 ZERO开发!
评论






