Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

BilalHaidar's avatar

Laravel Scheduler is still using my old code

Hello everyone,

I am hosting my app on Google Cloud and using a combination of a supervisord and script to keep running the scheduler every 1 minute.

One of the Commands I run via the Scheduler has its code changed. However, I am getting log errors showing that the old code is still being used.

I thought every time the Scheduler runs it will pick up the latest code, correct?

Thank you

0 likes
10 replies
migsAV's avatar

Try restarting your supervisord.

migsAV's avatar

I am not familiar with Google App Engine Flex so, unfortunately, I can assist any further.

Snapey's avatar

which command do you run? schedule:work or schedule:run ?

Dont you have the option of cron on google cloud?

BilalHaidar's avatar

I use the following setup:

// additional-supervisord.conf

[program:cron-artisan]
command = bash %(ENV_APP_DIR)s/cron-artisan-schedule.sh
stdout_logfile = /dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile = /dev/stderr
stderr_logfile_maxbytes=0
user = www-data
numprocs = 1
autostart = true
autorestart = true
priority = 5
stopwaitsecs = 20

And the script is:

#!/bin/bash

# source: https://gist.github.com/dzuelke/5cd7e4772120ba098a8427e1efbc61a9

topofminute() {
	local now;
	
	while true; do
		now=$(date "+%S")
		now=${now#0} # strip leading zero for arithmetic operations
		
		# run command only if less than ten seconds have passed in the current minute
		if [[ "$now" -le 10 ]]; then
			# run command in the background
			"$@" &
		fi
		
		# echo "sleeping for $((61-now)) seconds..."
		
		sleep $((61-now))
	done
}

topofminute php artisan schedule:run
Snapey's avatar

when you deploy, do you overwrite the current code or deploy to a new folder and then change the ENV_APP_DIR ?

BilalHaidar's avatar

I deploy a new version everytime. This means, supervisord is already restarted. That's why I am not getting why the Scheduler is still using the old code and not the new one. Bottom line, the new code overrides the old code

Snapey's avatar

what I'm getting at, is if ENV_APP_DIR is changing correctly, or are you saying that it should always be the same value?

You restart supervisor as part of deployment?

BilalHaidar's avatar

How can I tell if ENV_APP_DIR is changing? The same folder is being deployed.

In general, with every new version deployment on Google App Engine Flex, supervisord gets restarted on it's own.

1 like
zim478's avatar

@BilalHaidar Hi Bilal, did you ever solve this issue. I have a very similar set up and I am having similar troubles. For some reason, even if I update the command to not 'ENV_APP_DIR', it still says I don't specify it. When I do specify 'APP_DIR' to any path, it tells me that the variable does not exist.

Please or to participate in this conversation.