Echa un vistazo al programa "nohup".
Recomendaría usar GNU Screen. Le permite desconectarse del servidor mientras todos sus procesos continúan ejecutándose. No sé cómo viví sin él antes de saber que existía.
Cuando se cierra la sesión, el proceso recibe la señal SIGHUP que aparentemente no capta. Puedes usar el nohup
comando al iniciar el proceso o el comando integrado de bash disown -h
después de iniciar el proceso para evitar que esto suceda:
> help disown
disown: disown [-h] [-ar] [jobspec ...]
By default, removes each JOBSPEC argument from the table of active jobs.
If the -h option is given, the job is not removed from the table, but is
marked so that SIGHUP is not sent to the job if the shell receives a
SIGHUP. The -a option, when JOBSPEC is not supplied, means to remove all
jobs from the job table; the -r option means to remove only running jobs.