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

darkzone's avatar

Laravel served with Docker Compose via PHP FPM cache issue

Laravel app in Docker imports a daily CSV generated by SAP at 04:00. A server cron at 04:15 copies the file from an SMB-mounted path into the app container; a Laravel scheduled job runs at 04:30 to import it.

Despite logs confirming the new file was copied into the container at 04:15, the scheduled import sometimes reads the previous day’s file. The job’s logs show the previous file’s mtime/MD5. A manual Job re-run later (via tinker) imports the correct file without any new copy happening.

Initially I was replacing storage/app/import_files/orders.csv in place. I then changed to copying files with unique timestamped names and made the job pick the latest CSV by mtime to avoid fixed-filename and cache issues.

Unfortunately, the issue still occurs everyday. I’m looking for ideas on what could cause a scheduled job to see stale file contents/metadata inside Docker despite the file being present and verified via docker exec (stat/md5) before the job runs.

0 likes
2 replies
Glukinho's avatar

the scheduled import sometimes reads the previous day’s file

How exactly this scheduled tasks takes file to process? I mean, how "last file" is defined? By name, by modification time?

Can you chain two tasks and pass actual file name from first to second, so the processing task gets explicit file name without need to "find" it somehow?

  1. copy task
  2. processing task

For example, using ->after(...):

$schedule->command(CopyFileCommand::class)->dailyAt('04:15')
	->after(function() {
		Artisan::call(ProcessFile::class, ['file_name' => 'yourfile.csv');
});
Glukinho's avatar

Or maybe using job chain:

Bus::chain([
    new CopyFileJob,
    new ProcessFileJob,
])->dispatch();

First job sets file name using

Context::put('file_name', 'myfile.csv');

Second job gets file name the same way:

$file_name = Context::get('file_name');

Please or to participate in this conversation.