我有一个symfony命令,我想从shell脚本中使用它。
例如:symfony我的命令。
我在项目文件夹中有一个脚本shell,我将symfony命令作为参数传递给它。
sh脚本:
time=$1
php_script_path=$2
log_file="script.log"
# Infinite loop
while true; do
# Loop over the PHP script until the timeout is reached
while timeout $time php $php_script_path; do
# This code will only execute if the PHP script exits successfully within the timeout period
echo "$(date): PHP script executed successfully" >> $log_file
done
# This code will only execute if the PHP script did not exit successfully within the timeout period
if [ $? -eq 124 ]; then
echo "$(date): PHP script timed out" >> $log_file
else
echo "$(date): PHP script completed with an error" >> $log_file
fi
done
1条答案
按热度按时间s8vozzvw1#
您可以使用与cron命令相同的命令。请在下面的PHP脚本中设置项目路径。