我想在Apache重新启动时运行一些特定于应用程序的清理代码。 首先,我遵循从https://stackoverflow.com/questions/2992938/is-it-possible-to-launch-a-php-script-at-apache-startup的步骤。 我使用Apache / 2.4.18在本地Ubuntu 16.04.1 LTS虚拟机上更改了/etc/init.d/apache2,在启动时添加了一些代码,并且工作完美。 但是当我尝试在AWS上使用Apache / 2.4.23时,在Ubuntu 16.04.2 LTS上执行完全相同的步骤时,几乎就像我的更改被忽略了一样。 我已经join了许多“回声”语句来理解正在发生的事情,但是我没有看到代码正在运行的任何符号。
这是我在/etc/init.d/apache2中改变的
start) log_daemon_msg "Starting $DESC" "$NAME" do_start RET_STATUS=$? case "$RET_STATUS" in 0|1) log_success_msg [ "$VERBOSE" != no ] && [ $RET_STATUS = 1 ] && log_warning_msg "Server was already running" ;; 2) log_failure_msg print_error_msg exit 1 ;; esac # Restart the reports that would have died when the server is restarted echo Restarting reports echo `date +%Y-%m-%d:%H:%M:%S` Starting report:restart_running_reports >> /var/www/application/storage/logs/restart_running_reports.log php /var/www/application/artisan report:restart_running_reports ;;