Knowledgebase

Running Long Tasks Without Losing Them Print

  • developersgitdeployment, developers, database, webhosting, redirects, cron, resourcelimits, troubleshooting
  • 0

Preventing a dropped connection killing a running job.

THE PROBLEM

A large database import, a long Composer install or a big file operation can take many minutes. If your connection drops, the command dies, possibly leaving things half-finished.

THE SOLUTIONS

screen or tmux, where available, create a session that persists on the server. Detach, reconnect later, and the work is still running.

Alternatively, run the command with nohup so it continues after disconnection, redirecting output to a file you can read afterwards.

ON SHARED HOSTING

screen and tmux may not be available. nohup usually is.

Be aware that shared hosting limits long-running processes. A command running for an hour may be terminated by resource limits regardless.

FOR VERY LONG OPERATIONS

Break the work into chunks. Importing a large database in sections is more reliable than one enormous operation that may be killed partway.

Or run it as a cron job, which is not tied to your session at all.

CHECKING PROGRESS

Redirect output to a log file and watch it with tail -f from a separate session.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot