一、指定php版运行,
cd /www/wwwroot/www.xxx.com/ && /www/server/php/56/bin/php think timedtasks start >> /tmp/timedtasks.log 2>&1
二、不指定php版
cd /www/wwwroot/www.xxx.com/ && php think timedtasks start >> /tmp/timedtasks.log 2>&1
或
# 使用绝对路径(通过 which php 获取)
cd /www/wwwroot/www.xxx.com/ && /usr/bin/php think timedtasks start >> /tmp/timedtasks.log 2>&1
切换工作目录
cd /www/wwwroot/www.xxx.com/
确保 PHP 脚本在项目根目录下执行,避免因相对路径导致的文件找不到问题(常见于框架的入口文件、配置文件加载)。
指定 PHP 版本路径
/www/server/php/56/bin/php
直接使用绝对路径调用 PHP 5.6 的解释器,避免系统默认 PHP 版本冲突。
执行命令
think timedtasks start
假设这是你的项目自定义命令(如 ThinkPHP 框架的定时任务)。
日志记录(可选但强烈建议)
>> /tmp/timedtasks.log 2>&1
将标准输出和错误信息重定向到日志文件,便于后续排查问题