The default setting given to delete temp files is after 6 hours minimum. I have users upload files and I want that if it has temp status, delete it after 15 secs. Tweaking the file module code is risky, if I get the exact location to change 6 hours to 15 sec that will do the job.
The value stored in this config
You can update that with the value you wants.
If you want to change the form as well which is recommended use hook_form_FORM_ID_alter to adjust the system file settings from
The current implementation looks like this
$intervals = [0, 21600, 43200, 86400, 604800, 2419200, 7776000]; $period = array_combine($intervals, array_map([$this->dateFormatter, 'formatInterval'], $intervals)); $period = $this->t('Never'); $form['temporary_maximum_age'] = [ '#type' => 'select', '#title' => $this->t('Delete temporary files after'), '#default_value' => $config->get('temporary_maximum_age'), '#options' => $period, '#description' => $this->t('Temporary files are not referenced, but are in the file system and therefore may show up in administrative lists. <strong>Warning:</strong> If enabled, temporary files will be permanently deleted and may not be recoverable.'), ];
You can alter the form and adjust it to what you want.
Keep in mind, to see this happen your corn must run at least every 15 sec.