Implement TUXIS_APPEND_RANDOM
tuxis-cron writes to a temporary log file. This log file is identified by the PID. On a 'normal' system, this works fine, e.g.:
- tuxis-cron process 1, with PID 42127. This process writes to a temporary log file ending with
.TMP.42127
and, whenMASTERLOG
is set, moves that file toMASTERLOG
. - tuxis-cron process 2, with PID 42224. This process writes to a temporary log file ending with
.TMP.42224
and, whenMASTERLOG
is set, moves that file toMASTERLOG
.
However, in some cases, PIDs may not be unique. E.g. when running tuxis-cron in a dedicated namespace where tuxis-cron is always the first process. This is a problem when both processes write to the same temporary log file (e.g. when MASTERLOG
is set to a file in a directory that is shared between the namespaces, or the default /tmp
is), e.g.:
- tuxis-cron process 1, with PID 3. This process writes to a temporary log file ending with
.TMP.3
and, whenMASTERLOG
is set, moves that file toMASTERLOG
. - tuxis-cron process 2, with PID 3. This process writes to a temporary log file ending with
.TMP.3
and, whenMASTERLOG
is set, moves that file toMASTERLOG
.
Not only will both processes write to the same temporary log file, but when process 1 terminates, the cp
will fail as process 2 already cp
'ed the temporary log file.
This PR adds the TUXIS_APPEND_RANDOM
variable. When TUXIS_APPEND_RANDOM
is set to yes
, $RANDOM
is appended to the name of the temporary log file. This ensures that even when multiple tuxis-cron processes have the same PID, they write to different files.