<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Super Funicular</title>
    <description>The latest articles on DEV Community by Super Funicular (@superfunicular).</description>
    <link>https://dev.to/superfunicular</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3905292%2F0eab2966-f7d2-41d0-983d-d240a6caa5d4.jpg</url>
      <title>DEV Community: Super Funicular</title>
      <link>https://dev.to/superfunicular</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/superfunicular"/>
    <language>en</language>
    <item>
      <title>Six Camera Clips, a while read Loop, and a Count of 0: Bash Ran the Loop in a Subshell</title>
      <dc:creator>Super Funicular</dc:creator>
      <pubDate>Thu, 26 Nov 2026 13:56:36 +0000</pubDate>
      <link>https://dev.to/superfunicular/six-camera-clips-a-while-read-loop-and-a-count-of-0-bash-ran-the-loop-in-a-subshell-2aoo</link>
      <guid>https://dev.to/superfunicular/six-camera-clips-a-while-read-loop-and-a-count-of-0-bash-ran-the-loop-in-a-subshell-2aoo</guid>
      <description>&lt;p&gt;A clip script counts the camera clips in a folder by piping &lt;code&gt;find&lt;/code&gt; into a &lt;code&gt;while read&lt;/code&gt; loop and adding one per line. The folder has six clips. The script prints 0.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="nv"&gt;count&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0
find clips -name &lt;span class="s1"&gt;'*.mp4'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="nb"&gt;read&lt;/span&gt; -r f&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="nv"&gt;count&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;count + 1&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"clips counted: $count"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;clips counted: 0
[exit status 0]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The loop did run. Printing the counter on every pass shows it climbing to six, and then reading zero on the very next line after &lt;code&gt;done&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="nv"&gt;count&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0
find clips -name &lt;span class="s1"&gt;'*.mp4'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; sort &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="nb"&gt;read&lt;/span&gt; -r f&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="nv"&gt;count&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;count + 1&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"inside the loop after $f: count=$count"&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"after the loop: count=$count"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;inside the loop after clips/clip_01.mp4: count=1
inside the loop after clips/clip_02.mp4: count=2
inside the loop after clips/clip_03.mp4: count=3
inside the loop after clips/clip_04.mp4: count=4
inside the loop after clips/clip_05.mp4: count=5
inside the loop after clips/clip_06.mp4: count=6
after the loop: count=0
[exit status 0]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Disclosure: I make an Android camera app. Nothing below uses its code or describes how it records or stores anything. The clips are files of zeros made by the setup script below, and every output is pasted from the scripts shown. Versions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GNU bash, version 5.1.16(1)-release (aarch64-unknown-linux-gnu)
Linux 6.8.0-149-generic
find (GNU findutils) 4.8.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="c"&gt;# Six stand-in clips: five small ones and one of 9 MB. Plus an empty folder.&lt;/span&gt;
mkdir -p clips empty
&lt;span class="k"&gt;for&lt;/span&gt; i &lt;span class="k"&gt;in&lt;/span&gt; 1 2 3 4 5&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; head -c &lt;span class="nv"&gt;$(&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;i * 1000&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; /dev/zero &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"clips/clip_0$i.mp4"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;done&lt;/span&gt;
head -c 9000000 /dev/zero &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; clips/clip_06.mp4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The loop ran in a copy of the script
&lt;/h2&gt;

&lt;p&gt;The Bash manual covers this in its section on the command execution environment: "Builtin commands that are invoked as part of a pipeline, except possibly in the last element depending on the value of the lastpipe shell option (see The Shopt Builtin), are also executed in a subshell environment." The next sentence is the one that explains the zero: "Changes made to the subshell environment cannot affect the shell’s execution environment."&lt;/p&gt;

&lt;p&gt;The same page defines the word in one line: "A subshell is a copy of the shell process."&lt;/p&gt;

&lt;p&gt;So &lt;code&gt;while&lt;/code&gt;, &lt;code&gt;read&lt;/code&gt; and the arithmetic all ran, in a copy of the shell made for that part of the pipeline. The copy counted to six and then went away. The original script saw none of it and still had the &lt;code&gt;count=0&lt;/code&gt; it started with.&lt;/p&gt;

&lt;p&gt;Bash will show the copy directly. &lt;code&gt;$$&lt;/code&gt; keeps reporting the original script's process ID even inside a subshell, while &lt;code&gt;$BASHPID&lt;/code&gt; reports the process actually running the line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"script:      \$\$=$$ BASHPID=$BASHPID"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; x &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="nb"&gt;read&lt;/span&gt; -r _&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"loop body:   \$\$=$$ BASHPID=$BASHPID"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;script:      $$=30 BASHPID=30
loop body:   $$=30 BASHPID=32
[exit status 0]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Same &lt;code&gt;$$&lt;/code&gt;, different &lt;code&gt;$BASHPID&lt;/code&gt;. The loop body was running in another process.&lt;/p&gt;

&lt;h2&gt;
  
  
  The same copy swallows exit
&lt;/h2&gt;

&lt;p&gt;A counter that reads zero is easy to notice. The version of this bug that does damage is a safety check. Here the loop is meant to stop the whole upload if any clip is over 5 MB:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="c"&gt;# Stop the upload if any clip is larger than 5 MB.&lt;/span&gt;
find clips -name &lt;span class="s1"&gt;'*.mp4'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; sort &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="nb"&gt;read&lt;/span&gt; -r f&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;$(&lt;/span&gt;stat -c %s &lt;span class="s2"&gt;"$f"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; 5000000 &lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"too big: $f, stopping"&lt;/span&gt;
    &lt;span class="nb"&gt;exit&lt;/span&gt; 1
  &lt;span class="k"&gt;fi&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"uploading every clip"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="nv"&gt;big&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
find clips -name &lt;span class="s1"&gt;'*.mp4'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="nb"&gt;read&lt;/span&gt; -r f&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;$(&lt;/span&gt;stat -c %s &lt;span class="s2"&gt;"$f"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; 4000 &lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; big+=&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"$f"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"large clips found: ${#big[@]}"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;too big: clips/clip_06.mp4, stopping
uploading every clip
[exit status 0]
large clips found: 0
[exit status 0]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The size check found the 9 MB clip and printed its warning. Then &lt;code&gt;exit 1&lt;/code&gt; ended the subshell, not the script, and the script carried on to the line that uploads every clip, finishing with status 0. Anything that checks that status would see success.&lt;/p&gt;

&lt;p&gt;The second script collects the clips over 4000 bytes into an array. &lt;code&gt;clip_05&lt;/code&gt; and &lt;code&gt;clip_06&lt;/code&gt; both qualify. The array the script reads after the loop is empty, for the same reason the counter was zero.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fix 1: feed the loop with process substitution
&lt;/h2&gt;

&lt;p&gt;Putting the loop at the front and feeding it from &lt;code&gt;&amp;lt; &amp;lt;(find ...)&lt;/code&gt; means the loop is no longer part of a pipeline. It runs in the script itself, and &lt;code&gt;find&lt;/code&gt; is the part that runs elsewhere:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="nv"&gt;count&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0
&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="nb"&gt;read&lt;/span&gt; -r f&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="nv"&gt;count&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;count + 1&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;find clips -name &lt;span class="s1"&gt;'*.mp4'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"clips counted: $count"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="nb"&gt;read&lt;/span&gt; -r f&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;$(&lt;/span&gt;stat -c %s &lt;span class="s2"&gt;"$f"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; 5000000 &lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"too big: $f, stopping"&lt;/span&gt;
    &lt;span class="nb"&gt;exit&lt;/span&gt; 1
  &lt;span class="k"&gt;fi&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;find clips -name &lt;span class="s1"&gt;'*.mp4'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; sort&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"uploading every clip"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;clips counted: 6
[exit status 0]
too big: clips/clip_06.mp4, stopping
[exit status 1]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The count is right, and the oversized clip now stops the script with status 1 before the upload line.&lt;/p&gt;

&lt;p&gt;There is a cost. &lt;code&gt;find&lt;/code&gt; now runs somewhere its exit status does not reach the script, so a typo in the folder name looks the same as an empty folder, even under &lt;code&gt;set -e&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; -e
&lt;span class="nv"&gt;count&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0
&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="nb"&gt;read&lt;/span&gt; -r f&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="nv"&gt;count&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;count + 1&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;find no_such_folder -name &lt;span class="s1"&gt;'*.mp4'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"clips counted: $count, script still running"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="nv"&gt;count&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0
&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="nb"&gt;read&lt;/span&gt; -r f&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="nv"&gt;count&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;count + 1&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;find no_such_folder -name &lt;span class="s1"&gt;'*.mp4'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;wait&lt;/span&gt; &lt;span class="nv"&gt;$!&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"find exited $?"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"clips counted: $count"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;find: ‘no_such_folder’: No such file or directory
clips counted: 0, script still running
[exit status 0]
find: ‘no_such_folder’: No such file or directory
find exited 1
clips counted: 0
[exit status 0]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;find&lt;/code&gt; complained, and the script still counted 0 and kept going with status 0. In the second script &lt;code&gt;wait $!&lt;/code&gt; straight after the loop recovered the exit status of &lt;code&gt;find&lt;/code&gt; as 1, which the script can then act on. If the folder might not exist, check that before the loop or collect that status.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fix 2: shopt -s lastpipe
&lt;/h2&gt;

&lt;p&gt;The manual's own exception is the &lt;code&gt;lastpipe&lt;/code&gt; option. With it set, Bash can run the last part of a pipeline in the script itself, so the original layout works:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="nb"&gt;shopt&lt;/span&gt; -s lastpipe
&lt;span class="nv"&gt;count&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0
find clips -name &lt;span class="s1"&gt;'*.mp4'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="nb"&gt;read&lt;/span&gt; -r f&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="nv"&gt;count&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;count + 1&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"clips counted: $count"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="nb"&gt;shopt&lt;/span&gt; -s lastpipe
find clips -name &lt;span class="s1"&gt;'*.mp4'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; sort &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="nb"&gt;read&lt;/span&gt; -r f&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;$(&lt;/span&gt;stat -c %s &lt;span class="s2"&gt;"$f"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; 5000000 &lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"too big: $f, stopping"&lt;/span&gt;
    &lt;span class="nb"&gt;exit&lt;/span&gt; 1
  &lt;span class="k"&gt;fi&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"uploading every clip"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;clips counted: 6
[exit status 0]
too big: clips/clip_06.mp4, stopping
[exit status 1]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both behave correctly. The manual hedges with the word possibly, and two cases from my runs show why:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; -m          &lt;span class="c"&gt;# job control on, as in an interactive terminal&lt;/span&gt;
&lt;span class="nb"&gt;shopt&lt;/span&gt; -s lastpipe
&lt;span class="nv"&gt;count&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0
find clips -name &lt;span class="s1"&gt;'*.mp4'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="nb"&gt;read&lt;/span&gt; -r f&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="nv"&gt;count&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;count + 1&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"clips counted: $count"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="nb"&gt;shopt&lt;/span&gt; -s lastpipe
&lt;span class="nv"&gt;count&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0
find clips -name &lt;span class="s1"&gt;'*.mp4'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="nb"&gt;read&lt;/span&gt; -r f&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="nv"&gt;count&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;count + 1&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"$f"&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; sort &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; list.txt
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"clips counted: $count, lines in list.txt: $(wc -l &amp;lt; list.txt)"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;clips counted: 0
[exit status 0]
clips counted: 0, lines in list.txt: 6
[exit status 0]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Job control on, back to zero.&lt;/strong&gt; &lt;code&gt;set -m&lt;/code&gt; turns on job control, as an interactive terminal has it. With that on, &lt;code&gt;lastpipe&lt;/code&gt; had no effect and the count was 0 again. A loop that works when run as a script can still read zero when someone pastes it into a terminal to test it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Loop not last, back to zero.&lt;/strong&gt; In the second script the loop's output goes on into &lt;code&gt;sort&lt;/code&gt;. The loop is no longer the last element, so it ran in a subshell anyway. The six lines reached &lt;code&gt;list.txt&lt;/code&gt; because they went through the pipe; the counter did not, because it lived in the copy.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One thing &lt;code&gt;lastpipe&lt;/code&gt; keeps that process substitution loses: &lt;code&gt;find&lt;/code&gt; is still part of the pipeline, so &lt;code&gt;pipefail&lt;/code&gt; sees its failure. With &lt;code&gt;set -e -o pipefail&lt;/code&gt;, the missing folder stops the script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; -e -o pipefail
&lt;span class="nv"&gt;count&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0
&lt;span class="nb"&gt;shopt&lt;/span&gt; -s lastpipe
find no_such_folder -name &lt;span class="s1"&gt;'*.mp4'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="nb"&gt;read&lt;/span&gt; -r f&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="nv"&gt;count&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;count + 1&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"clips counted: $count, script still running"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;find: ‘no_such_folder’: No such file or directory
[exit status 1]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The script stopped at the pipeline with status 1 and did not print its last line.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fix 3: when only exit matters, check the loop's status
&lt;/h2&gt;

&lt;p&gt;If the loop only needs to stop the script and sets nothing the script reads afterwards, the subshell can stay. The status of a pipeline is the status of its last command, which here is the loop, which is whatever the subshell exited with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
find clips -name &lt;span class="s1"&gt;'*.mp4'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; sort &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="nb"&gt;read&lt;/span&gt; -r f&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;$(&lt;/span&gt;stat -c %s &lt;span class="s2"&gt;"$f"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; 5000000 &lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"too big: $f, stopping"&lt;/span&gt;
    &lt;span class="nb"&gt;exit&lt;/span&gt; 1
  &lt;span class="k"&gt;fi&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"the loop exited $?, not uploading"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;exit&lt;/span&gt; 1&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"uploading every clip"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;too big: clips/clip_06.mp4, stopping
the loop exited 1, not uploading
[exit status 1]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;|| { ...; exit 1; }&lt;/code&gt; turns the subshell's &lt;code&gt;exit 1&lt;/code&gt; into the script's. This does nothing for counters or arrays, which are still lost.&lt;/p&gt;

&lt;h2&gt;
  
  
  Watch the here-string version on an empty folder
&lt;/h2&gt;

&lt;p&gt;Another common rewrite captures the list first and feeds it in with &lt;code&gt;&amp;lt;&amp;lt;&amp;lt;&lt;/code&gt;. It counts six on the full folder. On an empty folder it counts one:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="nv"&gt;count&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0
&lt;span class="nv"&gt;list&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;find empty -name &lt;span class="s1"&gt;'*.mp4'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="nb"&gt;read&lt;/span&gt; -r f&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="nv"&gt;count&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;count + 1&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s2"&gt;"$list"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"clips counted in an empty folder: $count"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="nv"&gt;count&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0
&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="nb"&gt;read&lt;/span&gt; -r f&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="nv"&gt;count&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;count + 1&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;find empty -name &lt;span class="s1"&gt;'*.mp4'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"clips counted in an empty folder: $count"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;clips counted in an empty folder: 1
[exit status 0]
clips counted in an empty folder: 0
[exit status 0]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;$(find ...)&lt;/code&gt; on an empty folder is an empty string, and &lt;code&gt;&amp;lt;&amp;lt;&amp;lt;&lt;/code&gt; adds a newline to what it is given, so &lt;code&gt;read&lt;/code&gt; gets one empty line and the loop runs once with &lt;code&gt;f&lt;/code&gt; set to nothing. The process substitution version reads no lines and counts 0. A here-string loop needs to skip lines where &lt;code&gt;f&lt;/code&gt; is empty, or a different feed.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to change in a script like this
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Look for any &lt;code&gt;| while read&lt;/code&gt; whose loop sets a variable, adds to an array, or calls &lt;code&gt;exit&lt;/code&gt;. Those are the ones where the change is lost.&lt;/li&gt;
&lt;li&gt;Prefer &lt;code&gt;done &amp;lt; &amp;lt;(find ...)&lt;/code&gt; in scripts that run anywhere, and check separately that the folder exists, since &lt;code&gt;find&lt;/code&gt; failing there is silent.&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;shopt -s lastpipe&lt;/code&gt; only in scripts that run without job control, and only when the loop is the last part of the pipeline. Pair it with &lt;code&gt;set -o pipefail&lt;/code&gt; to catch &lt;code&gt;find&lt;/code&gt; failing.&lt;/li&gt;
&lt;li&gt;If the loop exists only to stop the script, &lt;code&gt;done || exit 1&lt;/code&gt; after the pipeline is enough.&lt;/li&gt;
&lt;li&gt;Test the empty-folder case. A here-string feed counts one there.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Things I did not test
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Other Bash versions.&lt;/strong&gt; I ran 5.1. The quotes are from the current online manual, and what I ran matched them, but I did not run another version.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Other shells.&lt;/strong&gt; I did not run any shell other than Bash. Whether the last part of a pipeline runs in the current shell is one of the places shells are known to differ, so check yours rather than carrying these results over.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Odd filenames.&lt;/strong&gt; The clip names here have no spaces or newlines. &lt;code&gt;read -r&lt;/code&gt; with one name per line is not safe for names that contain a newline, and I did not test those here.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Real uploads.&lt;/strong&gt; Nothing was uploaded. The upload line is an &lt;code&gt;echo&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Sources.&lt;/strong&gt; Quotes are from the GNU Bash Reference Manual page &lt;a href="https://www.gnu.org/software/bash/manual/html_node/Command-Execution-Environment.html" rel="noopener noreferrer"&gt;Command Execution Environment&lt;/a&gt;. Outputs are pasted unedited from the scripts above; only process IDs change between runs.&lt;/p&gt;

&lt;p&gt;If you want an old Android phone recording in the background so there is a folder of clips for a script like this to count, the app I make is &lt;a href="https://play.google.com/store/apps/details?id=com.superfunicular.digicam" rel="noopener noreferrer"&gt;Background Camera RemoteStream on Google Play&lt;/a&gt;. Nothing above depends on it.&lt;/p&gt;

&lt;p&gt;Whatever a piped loop changes stays behind in its subshell, so move the loop out of the pipeline with &lt;code&gt;&amp;lt; &amp;lt;(...)&lt;/code&gt;, or turn on &lt;code&gt;lastpipe&lt;/code&gt; where job control is off, and try it once against a folder with no clips in it.&lt;/p&gt;

</description>
      <category>bash</category>
      <category>linux</category>
      <category>devops</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Why Does My Samsung Phone Stop the Camera App After a Few Days? Sleeping Apps, Never Sleeping Apps and the 3-Day Rule (Works Without Internet)</title>
      <dc:creator>Super Funicular</dc:creator>
      <pubDate>Thu, 26 Nov 2026 08:13:31 +0000</pubDate>
      <link>https://dev.to/superfunicular/why-does-my-samsung-phone-stop-the-camera-app-after-a-few-days-sleeping-apps-never-sleeping-apps-1e4l</link>
      <guid>https://dev.to/superfunicular/why-does-my-samsung-phone-stop-the-camera-app-after-a-few-days-sleeping-apps-never-sleeping-apps-1e4l</guid>
      <description>&lt;p&gt;You set up an old Samsung Galaxy as a camera. It worked on the first night. You checked the next morning, the recording was fine, and you stopped worrying. A few days later you look again, and the camera app is not running. The last file ends days ago. Nothing crashed. There was no error.&lt;/p&gt;

&lt;p&gt;On Samsung phones this is very often not a broken phone and not a broken app. It is Samsung's own battery system, which puts apps you have not &lt;em&gt;opened&lt;/em&gt; for a few days to sleep. A camera phone that sits alone on a shelf is exactly that: an app you started once and then never touched again.&lt;/p&gt;

&lt;p&gt;This guide explains Samsung's &lt;strong&gt;Sleeping apps&lt;/strong&gt;, &lt;strong&gt;Deep sleeping apps&lt;/strong&gt; and &lt;strong&gt;Never sleeping apps&lt;/strong&gt; lists, the one switch that keeps putting apps back to sleep, and a test that actually catches the problem. A one-night test does not. It is written for a simple setup: one budget Galaxy phone (A, M, F or J series), no cloud account, no subscription, often with no SIM card and only home or shop Wi-Fi.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why does my Samsung phone stop the camera app after a few days?
&lt;/h2&gt;

&lt;p&gt;Because Samsung's app management watches how often you use each app, and after a few days of no use it can move an app into a "sleeping" list, where Android's background features are restricted.&lt;/p&gt;

&lt;p&gt;This is not a rumour. Samsung explains it on its own developer site, in a page called &lt;em&gt;Samsung Application Management&lt;/em&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Background applications that have not been used for about 3 days and causing poor system health (ex. battery consumption) will go into the sleeping mode."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And on what sleeping means:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"A bucket restriction applies to any sleeping applications, and features such as Job, Alarm, and Foreground-service are restricted."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;A &lt;strong&gt;foreground service&lt;/strong&gt; is the Android feature that lets an app keep working with the screen off. It is the reason a screen-off camera app shows a notification while it records. So a list that restricts foreground services is a list your camera app must not be on.&lt;/p&gt;

&lt;p&gt;There is a second, stronger list:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Applications that have not been used for a long period of time (currently set to 16 days, but subject to change according to Samsung policies) will go into the deep sleeping mode."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Samsung says deep sleeping apps "only become active when the user opens them," and "can't perform any activities, including notifications or updates."&lt;/p&gt;

&lt;p&gt;Two things are worth saying clearly, so nobody over-reads this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Samsung's wording has two conditions: &lt;em&gt;not used for about 3 days&lt;/em&gt; &lt;strong&gt;and&lt;/strong&gt; &lt;em&gt;causing poor system health (ex. battery consumption)&lt;/em&gt;. A camera that records all day does use battery. Samsung does not publish exactly how it measures either condition, so we cannot tell you that every camera app will be put to sleep on day 3. We can tell you the mechanism exists and that a camera phone fits its description well.&lt;/li&gt;
&lt;li&gt;"Used" most likely means &lt;em&gt;opened by you on that phone&lt;/em&gt;. A camera you start and then leave alone is, from the phone's point of view, an app nobody has opened for days. We do not know whether watching a live view from another device counts as use. Assume it does not.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Samsung's own fix: Never sleeping apps
&lt;/h2&gt;

&lt;p&gt;The same Samsung page gives the way out:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"If there are applications that need to be set aside as exceptions, the user can do so at the following path: Settings &amp;gt; Device care &amp;gt; Battery &amp;gt; Background usage limits"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;On newer phones the menu is called &lt;strong&gt;Battery and device care&lt;/strong&gt;. Samsung's US support page gives the path as: &lt;strong&gt;Settings → Battery and device care → Battery → Background usage limits&lt;/strong&gt;. On the newest software, Samsung's Bangladesh support page (updated December 2025) shows it as &lt;strong&gt;Settings → Battery → Background usage limits&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If none of these match, open &lt;strong&gt;Settings&lt;/strong&gt;, tap the search box at the top and type &lt;strong&gt;Background usage limits&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Inside you will find a switch and three lists. Samsung's US page describes them like this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Put unused apps to sleep:&lt;/strong&gt; "If you haven't used an app in a while, it will automatically be put to sleep."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sleeping apps:&lt;/strong&gt; apps that "may run in the background if you start to use them again."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Deep sleeping apps:&lt;/strong&gt; apps "that will never run in the background. They'll only work when you open them."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Never sleeping apps:&lt;/strong&gt; apps "that will never turn off or sleep in the background."&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The five Samsung settings for a screen-off camera phone
&lt;/h2&gt;

&lt;p&gt;Menu names change between One UI versions and between models. If a step does not match your phone, use the &lt;strong&gt;search box in Settings&lt;/strong&gt; and type the bold words.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Add the camera app to Never sleeping apps
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Background usage limits → Never sleeping apps → + (plus) → select your camera app → Add.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is the most important step on a Samsung phone. It is the exception list Samsung itself points to.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Make sure it is not in Sleeping apps or Deep sleeping apps
&lt;/h3&gt;

&lt;p&gt;Open both lists and look for your camera app. If it is there: tap &lt;strong&gt;More options&lt;/strong&gt; (the three dots) → &lt;strong&gt;Remove apps&lt;/strong&gt; → select it → &lt;strong&gt;Remove&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Check this even on a phone you set up yourself. Samsung's own support pages teach people to add "unused or infrequently used apps" to these lists to save battery. In a shared house or a shop, someone who wanted the phone to last longer may have done exactly that, and from their side the camera app looked like an app nobody uses.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Turn off "Put unused apps to sleep"
&lt;/h3&gt;

&lt;p&gt;Same screen, the switch at the top. Turn it &lt;strong&gt;off&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Why, if you already added the app to Never sleeping apps? Because the volunteer site Don't Kill My App, which tracks how phone brands treat background apps, warns on its Samsung page:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Make sure Put unused apps to sleep is disabled. Otherwise, Samsung will put your apps back to sleep after a few days (3 by default) even if you have woken them up manually!"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It also says the latest feedback suggests Samsung "may re-add them later after a firmware update." On a phone that is used only as a camera, turning this switch off costs very little battery. There are no other apps on it worth putting to sleep.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Set the app's battery use to Unrestricted
&lt;/h3&gt;

&lt;p&gt;Open &lt;strong&gt;Settings → Apps → [your camera app] → Battery&lt;/strong&gt; and choose &lt;strong&gt;Unrestricted&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;On older phones (Android 11 and 12) the same idea has a different name: &lt;strong&gt;Battery optimization → All apps → [your camera app] → Don't optimize&lt;/strong&gt;. On Android 9 and 10, check &lt;strong&gt;Background restriction&lt;/strong&gt; and make sure the app is allowed to use battery in the background.&lt;/p&gt;

&lt;p&gt;Unrestricted can drain the battery of a phone you carry around. A camera phone lives on a charger, so that is not a concern here. If the battery still drops while plugged in, the charger is the problem, not this setting. We explained that in &lt;a href="https://dev.to/superfunicular/why-does-my-phone-security-cameras-battery-drop-even-though-it-is-plugged-in-weak-chargers-thin-19db"&gt;Why Does My Phone Security Camera's Battery Drop Even Though It Is Plugged In?&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Turn off the phone-wide savers, and do not press "Optimise now"
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Power saving:&lt;/strong&gt; Samsung's support page says that when it is on, "your phone restricts background data use for unused apps." Turn it &lt;strong&gt;off&lt;/strong&gt;, and make sure it does not turn on by itself at low battery.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Adaptive battery:&lt;/strong&gt; Don't Kill My App recommends turning it off on Samsung phones. Find it with the Settings search box.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Device care → Optimise now:&lt;/strong&gt; Samsung's own page says device optimisation "removes unnecessary files and background apps." Do not tap it while the camera is recording. Tell anyone else who uses the phone.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Auto restart at set times:&lt;/strong&gt; a scheduled night restart stops the camera until someone opens it again. That one has its own guide: &lt;a href="https://dev.to/superfunicular/why-does-my-samsung-phone-camera-stop-recording-at-night-auto-restart-the-30-battery-rule-and-2nhh"&gt;Why Does My Samsung Phone Camera Stop Recording at Night?&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Two extras if your phone has them. Don't Kill My App says you can lock an app in &lt;strong&gt;Recent apps&lt;/strong&gt; (it calls this &lt;strong&gt;Keep open&lt;/strong&gt;) so it is not closed with the rest. And if the phone has Samsung's &lt;strong&gt;Good Guardians&lt;/strong&gt; app installed, its &lt;strong&gt;Battery Guardian&lt;/strong&gt; module has an &lt;strong&gt;App power saving&lt;/strong&gt; option that, per the same site, "can close any app, if it uses an increased amount of battery." Check that your camera app is not affected.&lt;/p&gt;

&lt;h2&gt;
  
  
  Which Samsung phones are most affected?
&lt;/h2&gt;

&lt;p&gt;Samsung made a public promise about newer phones. On its developer page it says:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Since One UI 6.0, foreground services of apps targeting Android 14 will be guaranteed to work as intended so long as they are developed according to Android's new foreground service API policy."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That is good news, but notice the three conditions: &lt;strong&gt;One UI 6 or newer&lt;/strong&gt;, an app &lt;strong&gt;built for Android 14&lt;/strong&gt;, and built &lt;strong&gt;the way Android's rules require&lt;/strong&gt;. Don't Kill My App still rates Samsung 5 out of 5 on its problem scale (read on 26 November 2026) and asks for feedback from Android 14 Samsung users.&lt;/p&gt;

&lt;p&gt;Most camera phones are not new. They are the old Galaxy A, J or M model from the drawer, often on Android 9, 10 or 11. Those versions are exactly where Don't Kill My App lists the sleeping lists, background restrictions and "Put unused apps to sleep" as active. If your camera phone is older than about 2021, do all five steps.&lt;/p&gt;

&lt;p&gt;The names you will see, by Android version, according to Don't Kill My App:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Android version on the phone&lt;/th&gt;
&lt;th&gt;What to look for&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Android 13 and newer&lt;/td&gt;
&lt;td&gt;Per-app battery (Unrestricted), Adaptive battery, Sleeping / Deep sleeping / Never sleeping apps&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Android 11 and 12&lt;/td&gt;
&lt;td&gt;Battery optimization, Auto-optimize, Adaptive battery, the sleeping lists&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Android 9 and 10 (Pie)&lt;/td&gt;
&lt;td&gt;Device care, Background restrictions, Sleeping apps, "Put unused apps to sleep", "Auto-disable unused apps"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Android 7 and 8&lt;/td&gt;
&lt;td&gt;App power monitor → add the app to &lt;strong&gt;Unmonitored apps&lt;/strong&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;To see your version: &lt;strong&gt;Settings → About phone → Software information&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Does this work without internet?
&lt;/h2&gt;

&lt;p&gt;Yes. None of these settings need internet, a SIM card or a Samsung account. They are switches on the phone.&lt;/p&gt;

&lt;p&gt;That matters for the common shop and home setup where the camera phone has no SIM and only joins the local Wi-Fi. Recording to the phone's own storage does not need internet. A live view inside the same Wi-Fi network does not need internet either, as long as the router stays on. Streaming to YouTube Live is different: that one needs a working internet connection.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why a one-night test is not enough on Samsung
&lt;/h2&gt;

&lt;p&gt;Most guides, including ours for other brands, say: start recording, turn the screen off, wait 10 minutes, then try a full night. On a Samsung phone that test can pass and the camera can still stop later, because Samsung's sleeping rule is measured in &lt;strong&gt;days&lt;/strong&gt;. A test that ends after one night ends before the rule could act.&lt;/p&gt;

&lt;p&gt;So do a &lt;strong&gt;four-day test&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Make the five changes above. &lt;strong&gt;Restart the phone&lt;/strong&gt; once.&lt;/li&gt;
&lt;li&gt;Open the camera app, &lt;strong&gt;start recording&lt;/strong&gt;, turn the screen off, and put the phone on the charger. &lt;strong&gt;Write down the date and time.&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Do not open the camera app on that phone for four days.&lt;/strong&gt; If you need to check, use a live view from another device, or look at the phone's notification bar without opening the app.&lt;/li&gt;
&lt;li&gt;On day four, check the recordings. Do the files continue past day three with no long gap?&lt;/li&gt;
&lt;li&gt;Then open &lt;strong&gt;Background usage limits&lt;/strong&gt; again. Is the camera app still in &lt;strong&gt;Never sleeping apps&lt;/strong&gt;, and still missing from the other two lists?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If there is a gap, note roughly when it started. A gap that starts around day three points to the sleeping lists. A gap that starts at the same time every night points to Auto restart. A gap that starts when someone used the phone points to Optimise now or Recent apps being cleared.&lt;/p&gt;

&lt;p&gt;Run this again after every &lt;strong&gt;One UI update&lt;/strong&gt;. Don't Kill My App reports that removed apps can be put back on the lists after a firmware update.&lt;/p&gt;

&lt;h2&gt;
  
  
  Low-memory phones: one more reason the camera can stop
&lt;/h2&gt;

&lt;p&gt;Many camera phones are older Galaxy A or J models with 2 GB or 3 GB of memory. On those, two different things can stop your camera:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Samsung's sleeping rules&lt;/strong&gt; (this guide). These are settings. You can change them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Android's low-memory killer.&lt;/strong&gt; When memory is full, Android itself closes apps. A foreground service ranks high, but it is not untouchable.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For the second one: use the phone only as a camera, remove apps you do not need, and do not run games or social apps beside it. We explained how Android chooses what to stop in &lt;a href="https://dev.to/superfunicular/a-foreground-service-is-not-immortal-what-androids-low-memory-killer-does-to-a-247-camera-on-a-2-1470"&gt;A Foreground Service Is Not Immortal&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick checklist for a Samsung camera phone
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[ ] Camera app in &lt;strong&gt;Never sleeping apps&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;[ ] Camera app &lt;strong&gt;not&lt;/strong&gt; in Sleeping apps or Deep sleeping apps&lt;/li&gt;
&lt;li&gt;[ ] &lt;strong&gt;Put unused apps to sleep: off&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;[ ] App battery: &lt;strong&gt;Unrestricted&lt;/strong&gt; (older phones: &lt;strong&gt;Don't optimize&lt;/strong&gt;)&lt;/li&gt;
&lt;li&gt;[ ] Power saving &lt;strong&gt;off&lt;/strong&gt;, and not set to turn on by itself&lt;/li&gt;
&lt;li&gt;[ ] Adaptive battery &lt;strong&gt;off&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;[ ] Nobody taps &lt;strong&gt;Optimise now&lt;/strong&gt; while it records&lt;/li&gt;
&lt;li&gt;[ ] &lt;strong&gt;Auto restart&lt;/strong&gt; at set times off (&lt;a href="https://dev.to/superfunicular/why-does-my-samsung-phone-camera-stop-recording-at-night-auto-restart-the-30-battery-rule-and-2nhh"&gt;guide&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;[ ] Four-day test done without opening the app&lt;/li&gt;
&lt;li&gt;[ ] Re-check the lists after every One UI update&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  If you have a different brand
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;OPPO, realme or vivo:&lt;/strong&gt; &lt;a href="https://dev.to/superfunicular/why-does-my-oppo-realme-or-vivo-phone-stop-the-camera-app-with-the-screen-off-auto-launch-2k21"&gt;Why Does My OPPO, realme or vivo Phone Stop the Camera App With the Screen Off?&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Redmi, POCO or Xiaomi:&lt;/strong&gt; &lt;a href="https://dev.to/superfunicular/why-does-my-redmi-poco-or-xiaomi-phone-stop-the-camera-app-with-the-screen-off-autostart-battery-29kg"&gt;Why Does My Redmi, POCO or Xiaomi Phone Stop the Camera App With the Screen Off?&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tecno, Infinix or itel:&lt;/strong&gt; &lt;a href="https://dev.to/superfunicular/why-does-my-tecno-infinix-or-itel-phone-stop-the-camera-app-with-the-screen-off-phone-master-fa4"&gt;Why Does My Tecno, Infinix or itel Phone Stop the Camera App With the Screen Off?&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Developers&lt;/strong&gt; who want the Android side (Doze, foreground services, and why vendor layers sit on top) can read &lt;a href="https://dev.to/superfunicular/why-does-my-android-camera-stop-recording-when-the-screen-turns-off-doze-workmanager-and-the-1a5d"&gt;Why Does My Android Camera Stop Recording When the Screen Turns Off?&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;New to this? Start with &lt;a href="https://dev.to/superfunicular/turn-an-old-android-phone-into-a-screen-off-security-camera-no-cloud-lan-only-5cll"&gt;Turn an old Android phone into a screen-off security camera (no cloud, LAN-only)&lt;/a&gt;, then come back to this checklist before you leave the phone alone.&lt;/p&gt;

&lt;h3&gt;
  
  
  Sources
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Samsung Developer — &lt;a href="https://developer.samsung.com/mobile/app-management.html" rel="noopener noreferrer"&gt;Samsung Application Management&lt;/a&gt; (3-day sleeping rule, restricted Job/Alarm/Foreground-service, 16-day deep sleeping, Never sleeping exception path, One UI 6 statement).&lt;/li&gt;
&lt;li&gt;Samsung US Support — &lt;a href="https://www.samsung.com/us/support/answer/ANS10003442/" rel="noopener noreferrer"&gt;Sleeping apps on your Galaxy device&lt;/a&gt; (Background usage limits path and list descriptions).&lt;/li&gt;
&lt;li&gt;Samsung Bangladesh Support — &lt;a href="https://www.samsung.com/bd/support/mobile-devices/what-to-do-when-your-samsung-galaxy-device-battery-drains-faster/" rel="noopener noreferrer"&gt;What to do when your Samsung Galaxy device battery drains faster&lt;/a&gt; (Settings → Battery path, Optimise now, Power saving, advice to add apps to the sleeping lists).&lt;/li&gt;
&lt;li&gt;Don't Kill My App — &lt;a href="https://dontkillmyapp.com/samsung" rel="noopener noreferrer"&gt;Samsung&lt;/a&gt; (re-sleep warning, firmware re-add report, settings by Android version, Keep open, Good Guardians; brand score read 26 November 2026).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Don't Kill My App is a volunteer project, not official Samsung documentation, and Samsung does not publish exactly how it decides an app is "unused." That is exactly why the four-day test matters more than the menu.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Background Camera RemoteStream&lt;/strong&gt; turns an Android phone into a screen-off camera: it records with the screen off and keeps recordings on the phone, with no cloud account needed. Its Pro tier adds a live browser view over your own Wi-Fi and YouTube Live streaming; check the Play listing for what is free and what is Pro.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Google Play: &lt;a href="https://play.google.com/store/apps/details?id=com.superfunicular.digicam" rel="noopener noreferrer"&gt;https://play.google.com/store/apps/details?id=com.superfunicular.digicam&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Website: &lt;a href="https://superfunicular.com" rel="noopener noreferrer"&gt;https://superfunicular.com&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>android</category>
      <category>samsung</category>
      <category>security</category>
      <category>privacy</category>
    </item>
    <item>
      <title>CamEar: an Android App With Camera Permission Can Partly Hear Your Speakerphone — and the Camera Toggle Doesn't Stop It</title>
      <dc:creator>Super Funicular</dc:creator>
      <pubDate>Wed, 25 Nov 2026 14:13:07 +0000</pubDate>
      <link>https://dev.to/superfunicular/camear-an-android-app-with-camera-permission-can-partly-hear-your-speakerphone-and-the-camera-43a0</link>
      <guid>https://dev.to/superfunicular/camear-an-android-app-with-camera-permission-can-partly-hear-your-speakerphone-and-the-camera-43a0</guid>
      <description>&lt;p&gt;A preprint posted on November 20 shows that on many Android phones, an app holding &lt;strong&gt;camera&lt;/strong&gt; permission can recover part of the speech your phone plays through its own loudspeaker. It does not need the microphone. The researchers call the attack CamEar. It reads the gyroscope data some phones attach to camera frames as metadata, and the vibration from the speaker shows up in that data. (&lt;a href="https://cyberinsider.com/android-camera-metadata-speakerphone-speech-leak/" rel="noopener noreferrer"&gt;CyberInsider&lt;/a&gt;, Nov 23; &lt;a href="https://gbhackers.com/new-android-camera-attack/" rel="noopener noreferrer"&gt;GBHackers&lt;/a&gt;, Nov 24; &lt;a href="https://arxiv.org/abs/2611.27964" rel="noopener noreferrer"&gt;the preprint&lt;/a&gt;.)&lt;/p&gt;

&lt;p&gt;This is a research result, not malware found in the wild. It is still worth ten minutes of your attention, because it changes what "allow camera access" actually grants.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the researchers found
&lt;/h2&gt;

&lt;p&gt;Both reports give the same numbers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;They tested &lt;strong&gt;50 Android phones&lt;/strong&gt; from &lt;strong&gt;10 vendors&lt;/strong&gt;, released between 2020 and 2026.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;37&lt;/strong&gt; exposed gyroscope readings through the Camera2 interface while a camera session was running.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;26&lt;/strong&gt; delivered those readings faster than &lt;strong&gt;200 samples per second&lt;/strong&gt;. Since Android 12, that is the default ceiling on the normal motion-sensor interface.&lt;/li&gt;
&lt;li&gt;Six phones delivered roughly &lt;strong&gt;800–1,000 samples per second&lt;/strong&gt;: the vivo X300s, X300 Pro and X200 Ultra, the Xiaomi 17T Pro, the Redmi K90 Max and the Honor Magic8 Pro Air.&lt;/li&gt;
&lt;li&gt;On those six, with the phone flat on a table playing English speech at full media volume, the recognizer averaged &lt;strong&gt;52.1% word accuracy&lt;/strong&gt;, with a best of &lt;strong&gt;61.8%&lt;/strong&gt;. Accuracy fell to 34.7% at 80% volume and 19.2% at 60%.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Why does this happen? Phones use the gyroscope to correct camera shake. Speech from the loudspeaker shakes the chassis slightly, and the gyroscope picks that up. Some vendors pass high-rate gyroscope readings to apps alongside each camera frame. Android rate-limits the normal motion-sensor interface, and turning off microphone access enforces that limit. The camera route skipped those limits.&lt;/p&gt;

&lt;h2&gt;
  
  
  The part that matters for everyday users
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The system "Camera access" switch is not the same as revoking an app's camera permission.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;On the high-rate phones that had both privacy switches, turning off camera access gave the app blank video frames, but the motion data kept coming. Turning off microphone access did not slow it down either. GBHackers puts it plainly: &lt;em&gt;"turning off the system camera switch is not the same as revoking an app's camera permission."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Keep the limits in proportion, too. The demonstrated attack targets audio &lt;strong&gt;the phone itself plays&lt;/strong&gt;: the other side of a speakerphone call, or a voice note played aloud. The researchers say earphone playback and ordinary room conversation pass little vibration into the handset. The result is a partial transcript, not a clean recording. It also needs an &lt;strong&gt;active camera session&lt;/strong&gt;, so an app has to be using the camera at that moment.&lt;/p&gt;

&lt;h2&gt;
  
  
  A 10-minute camera-permission audit
&lt;/h2&gt;

&lt;p&gt;None of these steps needs a patch or a new app.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;List what holds camera access.&lt;/strong&gt; Open &lt;em&gt;Settings → Security &amp;amp; privacy → Privacy → Permission manager → Camera&lt;/em&gt;. The path varies by vendor, so search Settings for "permission manager" if it differs. You will probably find apps you forgot ever said yes to.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Revoke anything that doesn't need it.&lt;/strong&gt; That includes a shopping app you scanned one barcode with in 2023. The researchers' own advice is to revoke camera permission from apps that don't need it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Downgrade "Allow all the time"-style grants to "Only while using the app" or "Ask every time"&lt;/strong&gt; wherever the app's job allows it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use earphones for sensitive calls and voice notes.&lt;/strong&gt; The leak depends on loudspeaker vibration, so earphones remove most of it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Watch the privacy indicator.&lt;/strong&gt; Since Android 12 the status bar shows an indicator while an app is using the camera. CamEar needs an active camera session, so an indicator you can't explain is the thing to investigate.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Let auto-reset work.&lt;/strong&gt; Android revokes permissions from apps you haven't opened in months. If you want to keep it on for most apps, we wrote up how &lt;a href="https://dev.to/superfunicular/the-camera-app-you-deliberately-never-open-android-hibernation-permission-auto-reset-and-the-one-i4g"&gt;hibernation and permission auto-reset behave for camera apps&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  If you build camera apps
&lt;/h2&gt;

&lt;p&gt;The fix the authors recommend belongs to vendors: keep raw stabilization data inside the camera subsystem, and apply Android's existing sensor limits and privacy controls to motion metadata. In their tests, capping the metadata at roughly 160–200 Hz cut average word accuracy to &lt;strong&gt;2.3%&lt;/strong&gt;, without making the camera hardware itself sample more slowly.&lt;/p&gt;

&lt;p&gt;App developers can still act on the same principle: &lt;strong&gt;don't collect what you don't use.&lt;/strong&gt; If your app iterates over every &lt;code&gt;CaptureResult&lt;/code&gt; key and logs, stores or uploads it all, vendor-specific motion keys go along for the ride. Read the specific keys your feature needs and drop the rest. Analytics and crash SDKs inside a camera app deserve the same scrutiny, because the researchers specifically mention that an embedded software component could collect these readings.&lt;/p&gt;

&lt;h2&gt;
  
  
  The question this puts to every camera app, ours included
&lt;/h2&gt;

&lt;p&gt;We build &lt;a href="https://superfunicular.com" rel="noopener noreferrer"&gt;Background Camera RemoteStream&lt;/a&gt;. It is an Android app that records video with the screen off and can stream to YouTube Live. A background camera app keeps a camera session open while you are not looking at it, so CamEar is exactly the kind of finding we should be judged against. We aren't going to wave it away.&lt;/p&gt;

&lt;p&gt;The fair test for any camera app, including ours, has three parts. &lt;strong&gt;Does it need the camera?&lt;/strong&gt; &lt;strong&gt;Does it need it when you aren't actively using it?&lt;/strong&gt; &lt;strong&gt;What leaves the phone?&lt;/strong&gt; Our answers: the camera is the whole product. You start and stop each recording or stream yourself, and the status-bar indicator shows while it runs. Recordings are saved to your phone, and the app doesn't need an account. If a camera app can't answer those three questions plainly, revoke its permission. That is the useful habit to take from this paper, whatever app it is.&lt;/p&gt;

&lt;p&gt;The stronger fix still belongs to phone makers: apply the same rate limits to camera metadata that Android already applies to the normal motion-sensor interface. Until they do, permission hygiene is the defense you control.&lt;/p&gt;




&lt;ul&gt;
&lt;li&gt;Google Play: &lt;a href="https://play.google.com/store/apps/details?id=com.superfunicular.digicam" rel="noopener noreferrer"&gt;Background Camera RemoteStream&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Website: &lt;a href="https://superfunicular.com" rel="noopener noreferrer"&gt;superfunicular.com&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Sources: &lt;a href="https://cyberinsider.com/android-camera-metadata-speakerphone-speech-leak/" rel="noopener noreferrer"&gt;CyberInsider, Nov 23 2026&lt;/a&gt; · &lt;a href="https://gbhackers.com/new-android-camera-attack/" rel="noopener noreferrer"&gt;GBHackers, Nov 24 2026&lt;/a&gt; · preprint by Guangyuan Ji, Wenjing Wang and Bingsheng Zhang, &lt;a href="https://arxiv.org/abs/2611.27964" rel="noopener noreferrer"&gt;arXiv 2611.27964&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>android</category>
      <category>privacy</category>
      <category>security</category>
      <category>mobile</category>
    </item>
    <item>
      <title>Grading the Nokia 30-Minute Screen-Off Test From the Clip Files: 67 Lines of Python That Find Where Recording Stopped</title>
      <dc:creator>Super Funicular</dc:creator>
      <pubDate>Wed, 25 Nov 2026 14:11:32 +0000</pubDate>
      <link>https://dev.to/superfunicular/grading-the-nokia-30-minute-screen-off-test-from-the-clip-files-67-lines-of-python-that-find-where-2c0b</link>
      <guid>https://dev.to/superfunicular/grading-the-nokia-30-minute-screen-off-test-from-the-clip-files-67-lines-of-python-that-find-where-2c0b</guid>
      <description>&lt;p&gt;Our guide to &lt;a href="https://dev.to/superfunicular/is-an-old-nokia-android-phone-good-as-a-security-camera-which-models-stop-apps-with-the-screen-off-583g"&gt;old Nokia Android phones as security cameras&lt;/a&gt; ends with a test: start recording, turn the screen off, wait 30 minutes, then check the recordings. Then repeat overnight.&lt;/p&gt;

&lt;p&gt;A reader pointed out why 30 minutes matters. The old Evenwell Power saver cut background apps at about 20 minutes, so a 10-minute test gives a false pass.&lt;/p&gt;

&lt;p&gt;But "check the recordings" hides real work. An overnight test is 8 hours of clips. You will not scrub through them. You need to know three things fast:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Did recording cover the whole window?&lt;/li&gt;
&lt;li&gt;If not, &lt;strong&gt;when&lt;/strong&gt; did it stop, measured from the moment the screen went off?&lt;/li&gt;
&lt;li&gt;Did it stop for good, or come back?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The answer to all three is already in the files. This post is a 67-line Python script that reads it, and the three test folders we ran it on.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the files already tell you
&lt;/h2&gt;

&lt;p&gt;Most phone camera apps split recording into segments and name each clip by its &lt;strong&gt;start time&lt;/strong&gt;, like &lt;code&gt;CAM_20261121_230000.mp4&lt;/code&gt;. Your app's naming may differ; adjust the pattern. Each clip also knows its own &lt;strong&gt;duration&lt;/strong&gt;, which &lt;code&gt;ffprobe&lt;/code&gt; (part of FFmpeg) prints.&lt;/p&gt;

&lt;p&gt;Start + duration = end. Line the clips up, and every space between one clip's end and the next clip's start is a gap.&lt;/p&gt;

&lt;p&gt;Two details matter:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Segment joins are not gaps.&lt;/strong&gt; A new segment often starts a second after the last one ends. The script allows 5 seconds.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;An unreadable clip is a gap.&lt;/strong&gt; If a recorder is stopped hard, a normal MP4 can be left without its index (the &lt;code&gt;moov&lt;/code&gt; atom), and no player can open it. &lt;code&gt;ffprobe&lt;/code&gt; says so, and the script counts that time as missing instead of crashing.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The script
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;#!/usr/bin/env python3&lt;/span&gt;
&lt;span class="s2"&gt;"""Grade a screen-off recording test from the clip files alone.
Usage: python3 gaps.py FOLDER SCREEN_OFF_TIME END_TIME
Times are local, YYYY-mm-dd HH:MM. Clip names must start with the
recording start time: CAM_YYYYmmdd_HHMMSS.mp4"""&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;subprocess&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timedelta&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;pathlib&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;Path&lt;/span&gt;

&lt;span class="no"&gt;GAP_OK&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;timedelta&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;seconds&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;      &lt;span class="c1"&gt;# a clean segment join is allowed this much&lt;/span&gt;
&lt;span class="no"&gt;NAME&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;compile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="s2"&gt;"(\d{8}_\d{6})"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;duration&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;out&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;subprocess&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"ffprobe"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"-v"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"error"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"-show_entries"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"format=duration"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
         &lt;span class="s2"&gt;"-of"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"default=nw=1:nk=1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;capture_output&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stdout&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;                  &lt;span class="c1"&gt;# unreadable clip: treat as missing&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;folder&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;off&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;end&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;off&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;strptime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;off&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"%Y-%m-%d %H:%M"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;end&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;strptime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;end&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"%Y-%m-%d %H:%M"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;clips&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;bad&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;folder&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;glob&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"*.mp4"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;NAME&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;continue&lt;/span&gt;
        &lt;span class="n"&gt;start&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;strptime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;group&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"%Y%m%d_%H%M%S"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;duration&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;bad&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;continue&lt;/span&gt;
        &lt;span class="n"&gt;clips&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;start&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;start&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;timedelta&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;seconds&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;clips&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;gaps&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cursor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;off&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;clips&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;off&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;end&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;continue&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;cursor&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="no"&gt;GAP_OK&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;gaps&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cursor&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;cursor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cursor&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;end&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;cursor&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="no"&gt;GAP_OK&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;gaps&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cursor&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;end&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;end&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;off&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;total_seconds&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;missing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;total_seconds&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;gaps&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"clips: {len(clips)}  unreadable: {len(bad)}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"window: {off:%H:%M} -&amp;gt; {end:%H:%M}  covered: {100*(total-missing)/total:.1f}%"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;gaps&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;mins&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;off&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;total_seconds&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt;
        &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"  gap {a:%H:%M:%S} -&amp;gt; {b:%H:%M:%S}  ({(b-a).total_seconds()/60:.1f} min)"&lt;/span&gt;
              &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"  starts {mins:.1f} min after screen off"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;gaps&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"verdict: full window recorded"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;first&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;gaps&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;off&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;total_seconds&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="mi"&gt;15&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;first&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;gaps&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;end&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="no"&gt;GAP_OK&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"verdict: stopped near 20 min and never came back -&amp;gt; vendor killer (Step 2a/2b)"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;gaps&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;end&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="no"&gt;GAP_OK&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"verdict: stopped at {gaps[-1][0]:%H:%M} and never came back -&amp;gt; check Battery Saver, Adaptive Battery, memory"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"verdict: recording has holes but resumed -&amp;gt; check the charger and storage first"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;gaps&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"__main__"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;argv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It needs Python 3 and FFmpeg's &lt;code&gt;ffprobe&lt;/code&gt; on a computer. Copy the clips off the phone first. It never changes the clips.&lt;/p&gt;

&lt;h2&gt;
  
  
  Three test folders
&lt;/h2&gt;

&lt;p&gt;We built three folders with FFmpeg (tiny 16×16 grey clips at 1 frame per second, so the durations are exact) and ran the script on each with Python 3.10.12.&lt;/p&gt;

&lt;h3&gt;
  
  
  A: the pass
&lt;/h3&gt;

&lt;p&gt;Screen off at 23:00. Six 5-minute segments, each starting 1 second after the last ended.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;clips: 6  unreadable: 0
window: 23:00 -&amp;gt; 23:30  covered: 100.0%
verdict: full window recorded
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The 1-second joins did not count. Exit code 0.&lt;/p&gt;

&lt;h3&gt;
  
  
  B: the 20-minute killer
&lt;/h3&gt;

&lt;p&gt;Same start, but the last segment is only 267 seconds long, so recording ends at 23:19:30.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;clips: 4  unreadable: 0
window: 23:00 -&amp;gt; 23:30  covered: 65.0%
  gap 23:19:30 -&amp;gt; 23:30:00  (10.5 min)  starts 19.5 min after screen off
verdict: stopped near 20 min and never came back -&amp;gt; vendor killer (Step 2a/2b)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;19.5 minutes of 30 recorded = 65.0%. The gap starts 19.5 minutes after screen off and runs to the end of the window. That is the Evenwell pattern from the guide's table, and the verdict line points back to its Step 2a and 2b.&lt;/p&gt;

&lt;p&gt;Note what a 10-minute test would have said about this phone: 100%, pass.&lt;/p&gt;

&lt;h3&gt;
  
  
  C: the night with holes
&lt;/h3&gt;

&lt;p&gt;Overnight, 23:00 to 07:00, sixteen 30-minute slots (each clip 1,799 s). The 03:30 clip is missing, and the 05:00 clip is a broken file with no index.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;clips: 14  unreadable: 1
window: 23:00 -&amp;gt; 07:00  covered: 87.5%
  gap 03:29:59 -&amp;gt; 04:00:00  (30.0 min)  starts 270.0 min after screen off
  gap 04:59:59 -&amp;gt; 05:30:00  (30.0 min)  starts 360.0 min after screen off
verdict: recording has holes but resumed -&amp;gt; check the charger and storage first
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;14 of 16 slots = 87.5%. Both holes are found, including the one a file listing would hide: the broken 05:00 clip is &lt;em&gt;there&lt;/em&gt;, it just holds nothing you can watch.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reading the verdict
&lt;/h2&gt;

&lt;p&gt;The three verdicts map to the guide's result table:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;What the script finds&lt;/th&gt;
&lt;th&gt;Likely cause&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Gap starts 15–25 min after screen off, never ends&lt;/td&gt;
&lt;td&gt;A vendor app killer is still active&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Gap starts later, never ends&lt;/td&gt;
&lt;td&gt;Battery Saver, Adaptive Battery, or memory pressure&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Holes, but recording came back&lt;/td&gt;
&lt;td&gt;Look at power and storage before battery settings&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;No gaps&lt;/td&gt;
&lt;td&gt;The phone is ready&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The third row is a judgement, not a measurement. A hole that heals means something restarted the recording, so a permanent app kill is less likely. A loose cable or a full card is a cheaper first check than a settings hunt.&lt;/p&gt;

&lt;p&gt;For the "same time every night" row in the guide, run the script once per night and compare the gap start times.&lt;/p&gt;

&lt;h2&gt;
  
  
  What this does not tell you
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Why&lt;/strong&gt; the recording stopped. The files show when, not who. On a Nokia, the guide's Step 1 (Android version) and Step 2 (Evenwell, DuraSpeed) are still how you find the cause.&lt;/li&gt;
&lt;li&gt;Whether the &lt;strong&gt;picture&lt;/strong&gt; is good. A covered window full of black frames still scores 100%.&lt;/li&gt;
&lt;li&gt;Anything about clips named by &lt;strong&gt;end&lt;/strong&gt; time, or apps that record one long file. Change the &lt;code&gt;NAME&lt;/code&gt; pattern or the duration logic for those.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Same test, any phone
&lt;/h2&gt;

&lt;p&gt;Nothing here is Nokia-specific. The 20-minute line is, but the method works for the &lt;a href="https://dev.to/superfunicular/why-does-my-motorola-phone-stop-the-camera-app-with-the-screen-off-unrestricted-battery-usage-2apn"&gt;Motorola&lt;/a&gt;, &lt;a href="https://dev.to/superfunicular/why-does-my-redmi-poco-or-xiaomi-phone-stop-the-camera-app-with-the-screen-off-autostart-battery-29kg"&gt;Redmi&lt;/a&gt; and &lt;a href="https://dev.to/superfunicular/why-does-my-oneplus-phone-stop-the-camera-app-with-the-screen-off-battery-optimization-that-resets-3128"&gt;OnePlus&lt;/a&gt; guides too. Change the 15–25 minute window to whatever cut-off your brand is known for.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Background Camera RemoteStream&lt;/strong&gt; turns an Android phone into a screen-off camera: it records with the screen off and keeps recordings on the phone, with no cloud account needed. Its Pro tier adds a live browser view over your own Wi-Fi and YouTube Live streaming; check the Play listing for what is free and what is Pro.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Google Play: &lt;a href="https://play.google.com/store/apps/details?id=com.superfunicular.digicam" rel="noopener noreferrer"&gt;https://play.google.com/store/apps/details?id=com.superfunicular.digicam&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Website: &lt;a href="https://superfunicular.com" rel="noopener noreferrer"&gt;https://superfunicular.com&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>python</category>
      <category>android</category>
      <category>tutorial</category>
      <category>security</category>
    </item>
    <item>
      <title>Should You Record Your Parcel Unboxing? Open Box Delivery Rules, and How to Film the Handover With an Old Phone (Screen Off, No Internet)</title>
      <dc:creator>Super Funicular</dc:creator>
      <pubDate>Wed, 25 Nov 2026 13:57:37 +0000</pubDate>
      <link>https://dev.to/superfunicular/should-you-record-your-parcel-unboxing-open-box-delivery-rules-and-how-to-film-the-handover-with-4oa7</link>
      <guid>https://dev.to/superfunicular/should-you-record-your-parcel-unboxing-open-box-delivery-rules-and-how-to-film-the-handover-with-4oa7</guid>
      <description>&lt;p&gt;Sale season means more parcels. And more parcels means more of the problem everyone has heard about: a box arrives sealed, and inside is the wrong item, an empty space, or something broken.&lt;/p&gt;

&lt;p&gt;The common advice is: &lt;strong&gt;"record a video when you open the parcel."&lt;/strong&gt; People do it with the phone in one hand and the box cutter in the other. Often the video starts too late, misses the courier label, or the phone screen locks halfway.&lt;/p&gt;

&lt;p&gt;This guide is about doing it better with &lt;strong&gt;an old Android phone you already own&lt;/strong&gt;, fixed in one place, recording with the screen off, saving everything on the phone. No internet plan, no cloud account, no subscription.&lt;/p&gt;

&lt;p&gt;But first, the honest part: what the shopping platforms actually say.&lt;/p&gt;

&lt;h2&gt;
  
  
  Does Flipkart or Amazon require an unboxing video for a refund?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Short answer:&lt;/strong&gt; In the official pages we could find, &lt;strong&gt;no.&lt;/strong&gt; Neither Flipkart's Open Box Delivery terms nor Amazon.in's Open Box Inspection help page mentions an unboxing video as a requirement. What they describe instead is an &lt;strong&gt;inspection at your door, before you accept the parcel.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;An unboxing video is something buyers do on their own as evidence. Some buyers report on forums that a clear video helped their claim. Others report that it did not. A 2024 news report from India described a buyer who opened his phone order in front of the delivery person and shared an unboxing video, and still said his return requests were rejected. So treat a video as &lt;strong&gt;useful evidence, not a guarantee.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What Flipkart Open Box Delivery says
&lt;/h3&gt;

&lt;p&gt;Flipkart's own guide to Open Box Delivery (OBD) describes it like this:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"The Flipkart Wishmaster opens the packaging in your presence. You can check for damages, correct items, and ensure everything is intact before confirming your order."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If something is wrong, the same guide says you can refuse it at the door:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Upon receiving a wrong or damaged item, you can enjoy easy returns by asking the Flipkart Wishmaster to cancel the delivery and return it to the origin."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The guide says OBD covers eligible products such as mobiles, laptops and large appliances, "in select locations," and is "Applicable only to select products." Flipkart also has a separate terms page for OBD (linked in Sources); read it for your order before you rely on any of this.&lt;/p&gt;

&lt;h3&gt;
  
  
  What Amazon.in Open Box Inspection says
&lt;/h3&gt;

&lt;p&gt;Amazon.in's help page describes a similar service: the delivery associate unpacks the package at delivery so you can check it, and you share a code only if the item is correct and not damaged. The help page we found has two versions that differ in details such as which product categories qualify and whether there is a fee, so &lt;strong&gt;check the current page and your order screen&lt;/strong&gt; before relying on it.&lt;/p&gt;

&lt;h3&gt;
  
  
  The point most people miss
&lt;/h3&gt;

&lt;p&gt;Both services work around &lt;strong&gt;one moment: the doorstep, before you share the OTP or code.&lt;/strong&gt; Once you accept, your options may become narrower. One version of Amazon's terms says return requests for damage, missing parts or a wrong item will not be accepted after the code is shared and the order is delivered.&lt;/p&gt;

&lt;p&gt;So the most valuable video is not the one you take later at the kitchen table. It is the one that shows &lt;strong&gt;the handover and the inspection at the door.&lt;/strong&gt; That is exactly the moment when your hands are busy and your phone is in your pocket.&lt;/p&gt;

&lt;p&gt;That is where a fixed camera helps.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why a fixed old phone is better than holding your own phone
&lt;/h2&gt;

&lt;p&gt;When you hold the phone yourself:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You start recording after the box is already in your hand.&lt;/li&gt;
&lt;li&gt;You cannot hold the phone, check the item and talk to the delivery person at once.&lt;/li&gt;
&lt;li&gt;The screen may lock, a call may come in, and the recording stops.&lt;/li&gt;
&lt;li&gt;The video is on your main phone, mixed with everything else.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A second phone fixed on a shelf or the wall near the door fixes all four:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It is &lt;strong&gt;already recording&lt;/strong&gt; when the delivery person arrives.&lt;/li&gt;
&lt;li&gt;Your hands are free.&lt;/li&gt;
&lt;li&gt;With an app that records &lt;strong&gt;with the screen off&lt;/strong&gt;, there is no screen to lock and nothing to tap.&lt;/li&gt;
&lt;li&gt;The footage stays on that phone, separate from your personal phone.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Setup: old phone as a doorstep and counter camera
&lt;/h2&gt;

&lt;p&gt;This works for a home door, a gate, or a small shop counter where couriers and wholesale parcels arrive.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Pick the spot
&lt;/h3&gt;

&lt;p&gt;Point the camera so one frame shows:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Where the delivery person stands&lt;/strong&gt; at handover.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A flat surface&lt;/strong&gt; (table, shelf, counter) where the box is opened.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A wide view of both is better than a close view of one. If you can, keep the shipping label side of the box facing the camera when you put it down.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Mount and power the phone
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Use any cheap phone stand, a shelf, or a strong tape mount.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keep the phone plugged in.&lt;/strong&gt; A camera that runs all day must run on the charger, not the battery.&lt;/li&gt;
&lt;li&gt;Avoid pointing it at a bright window or doorway glare. A backlit door makes the delivery person a dark shape.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 3: Set the clock
&lt;/h3&gt;

&lt;p&gt;Open &lt;strong&gt;Settings&lt;/strong&gt; and make sure &lt;strong&gt;automatic date and time&lt;/strong&gt; is on. A video's file time is only useful if the phone's clock is right. If the phone has no SIM and no Wi-Fi, set the time manually and check it again after any restart.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4: Install the camera app and start recording with the screen off
&lt;/h3&gt;

&lt;p&gt;Install &lt;strong&gt;Background Camera RemoteStream&lt;/strong&gt; from Google Play, start recording, and turn the screen off. Recording continues with the screen off, and the files are saved &lt;strong&gt;on the phone&lt;/strong&gt;. No account and no cloud upload are needed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 5: Stop the phone from killing the app
&lt;/h3&gt;

&lt;p&gt;Budget phones often stop background apps to save battery. Before you trust the camera on a delivery day:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Set the app's battery usage to &lt;strong&gt;Unrestricted&lt;/strong&gt; (or "Don't optimize").&lt;/li&gt;
&lt;li&gt;Turn &lt;strong&gt;Battery Saver off&lt;/strong&gt; on that phone.&lt;/li&gt;
&lt;li&gt;Check your brand's extra killer (auto-start, "Phone Master", deep optimization). We have brand guides for Samsung, Xiaomi, OPPO/realme/vivo, Tecno/Infinix/itel and more, linked at the end.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 6: Test before the real delivery
&lt;/h3&gt;

&lt;p&gt;Record for &lt;strong&gt;30 minutes with the screen off&lt;/strong&gt;, then play the file. Then do a full day. If the file stops early, the problem is the phone's battery settings, not the parcel.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to do when the delivery arrives
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Check the camera is recording&lt;/strong&gt; before you open the door (if you use live view, glance at it; otherwise trust your test).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hold the sealed box up to the camera&lt;/strong&gt; for a few seconds, label side visible.&lt;/li&gt;
&lt;li&gt;If the order is Open Box Delivery or Open Box Inspection, &lt;strong&gt;let the inspection happen in front of the camera,&lt;/strong&gt; on the table or counter.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Only share the OTP or code after&lt;/strong&gt; you have seen the correct item, undamaged, with its accessories.&lt;/li&gt;
&lt;li&gt;If something is wrong, &lt;strong&gt;refuse at the door,&lt;/strong&gt; as the platform terms describe. Your video now shows the box arriving, the opening, and the problem.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Copy the clip off the phone the same day&lt;/strong&gt; (USB cable to a computer, or to your main phone). Keep the original file; don't trim it or send only a compressed copy.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Keep the evidence safe
&lt;/h2&gt;

&lt;p&gt;A video you cannot find later is no evidence at all.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Storage:&lt;/strong&gt; a full card or full phone storage stops recording. If you add a memory card, test it first. Cheap fake cards are common.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cleaner apps:&lt;/strong&gt; storage cleaners and "free up space" tools can delete large video files. Exclude the camera folder or don't run them on the camera phone.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Power cuts:&lt;/strong&gt; the phone's own battery keeps it recording through a short cut, as long as the battery is healthy. That is one reason an old phone beats a plug-in-only camera.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Optional: watch from another room without internet
&lt;/h2&gt;

&lt;p&gt;If you want to see the door from the kitchen or the back of a shop, the app's &lt;strong&gt;Pro&lt;/strong&gt; tier adds a live view in a browser over &lt;strong&gt;your own Wi-Fi&lt;/strong&gt;. It works on the local network, so it does not need an internet plan. If you have no router, a hotspot from a second phone can make that local network.&lt;/p&gt;

&lt;p&gt;The Pro tier also offers YouTube Live streaming, which does need internet. For parcel evidence, local recording is what matters.&lt;/p&gt;

&lt;h2&gt;
  
  
  Be fair to the delivery person
&lt;/h2&gt;

&lt;p&gt;The person at your door is doing a hard job, usually for little pay, and the problem is almost never their fault. A visible camera and a calm "I am recording the opening for the platform" is better than a hidden camera. Point the camera at the door area and table, not into the street or a neighbour's home. Rules about recording people, and especially audio, differ by country, so check local rules if you are unsure.&lt;/p&gt;

&lt;h2&gt;
  
  
  Limits to be honest about
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A video does not guarantee a refund.&lt;/strong&gt; Platform policies decide, and they change.&lt;/li&gt;
&lt;li&gt;The phone records what it sees. It does not send alerts, detect motion or read labels.&lt;/li&gt;
&lt;li&gt;A dark doorway at night makes poor footage. Add a light or move the table.&lt;/li&gt;
&lt;li&gt;Check the Play listing for what is free and what is Pro, and whether the app installs on your phone.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Related reading
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev.to/superfunicular/how-to-watch-your-shop-with-an-old-android-phone-no-internet-plan-no-subscription-no-credit-card-1bdl"&gt;How to Watch Your Shop With an Old Android Phone — No Internet Plan, No Subscription, No Credit Card&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/superfunicular/how-to-watch-your-front-porch-with-an-old-android-phone-screen-off-no-doorbell-no-subscription-22ii"&gt;How to Watch Your Front Porch With an Old Android Phone (Screen-Off, No Doorbell, No Subscription)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/superfunicular/is-my-cheap-128-gb-sd-card-fake-how-to-test-a-memory-card-before-it-goes-in-an-offline-phone-dd0"&gt;Is My Cheap 128 GB SD Card Fake? How to Test a Memory Card Before It Goes in an Offline Phone Security Camera&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/superfunicular/why-did-my-phone-security-cameras-recordings-disappear-cleaner-apps-google-photos-free-up-1c5k"&gt;Why Did My Phone Security Camera's Recordings Disappear? Cleaner Apps, Google Photos 'Free Up Space' and More&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/superfunicular/what-happens-to-a-phone-security-camera-during-a-power-cut-or-an-internet-outage-they-are-not-the-40o5"&gt;What Happens to a Phone Security Camera During a Power Cut or an Internet Outage?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/superfunicular/how-to-use-an-old-phone-as-a-security-camera-without-a-wi-fi-router-the-hotspot-setup-nobody-1bd5"&gt;How to Use an Old Phone as a Security Camera Without a Wi-Fi Router: The Hotspot Setup&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Brand battery guides: &lt;a href="https://dev.to/superfunicular/why-does-my-samsung-phone-camera-stop-recording-at-night-auto-restart-the-30-battery-rule-and-2nhh"&gt;Samsung&lt;/a&gt; · &lt;a href="https://dev.to/superfunicular/why-does-my-redmi-poco-or-xiaomi-phone-stop-the-camera-app-with-the-screen-off-autostart-battery-29kg"&gt;Redmi, POCO, Xiaomi&lt;/a&gt; · &lt;a href="https://dev.to/superfunicular/why-does-my-tecno-infinix-or-itel-phone-stop-the-camera-app-with-the-screen-off-phone-master-fa4"&gt;Tecno, Infinix, itel&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Sources
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Flipkart Stories — &lt;a href="https://stories.flipkart.com/open-box-delivery-flipkart-customer-trust" rel="noopener noreferrer"&gt;With Open Box Delivery, Flipkart Safeguards Customer Interests and Fosters Trust&lt;/a&gt;, read 25 November 2026 (quotes above are verbatim).&lt;/li&gt;
&lt;li&gt;Flipkart — &lt;a href="https://www.flipkart.com/pages/obd-tnc" rel="noopener noreferrer"&gt;Open Box Delivery: Terms and Conditions&lt;/a&gt; (the binding terms; check them for your order).&lt;/li&gt;
&lt;li&gt;Amazon.in — &lt;a href="https://www.amazon.in/gp/help/customer/display.html?nodeId=GNHMSYW5BTFBTMEW" rel="noopener noreferrer"&gt;Open Box Inspection&lt;/a&gt; and &lt;a href="https://www.amazon.in/gp/help/customer/display.html?nodeId=TpCYK1p37flRka6abZ" rel="noopener noreferrer"&gt;Open Box Inspection – Terms and Conditions&lt;/a&gt;, summarised from search results on 25 November 2026; versions differ, check the live page.&lt;/li&gt;
&lt;li&gt;Benzinga India — &lt;a href="https://in.benzinga.com/content/37815055/nothing-phone-order-turns-into-e-commerce-nightmare-as-flipkart-stalls-return" rel="noopener noreferrer"&gt;Nothing Phone order turns into e-commerce nightmare as Flipkart stalls return&lt;/a&gt; (buyer with an unboxing video whose return was reportedly refused).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is practical guidance, not legal advice. Platform terms change; your order page is the final word.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Background Camera RemoteStream&lt;/strong&gt; turns an Android phone into a screen-off camera: it records with the screen off and keeps recordings on the phone, with no cloud account needed. Its Pro tier adds a live browser view over your own Wi-Fi and YouTube Live streaming; check the Play listing for what is free and what is Pro, and whether it installs on your phone.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Google Play: &lt;a href="https://play.google.com/store/apps/details?id=com.superfunicular.digicam" rel="noopener noreferrer"&gt;https://play.google.com/store/apps/details?id=com.superfunicular.digicam&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Website: &lt;a href="https://superfunicular.com" rel="noopener noreferrer"&gt;https://superfunicular.com&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>android</category>
      <category>privacy</category>
      <category>tutorial</category>
      <category>mobile</category>
    </item>
    <item>
      <title>Is an Old Nokia Android Phone Good as a Security Camera? Which Models Stop Apps With the Screen Off (Evenwell, DuraSpeed) and a 30-Minute Test</title>
      <dc:creator>Super Funicular</dc:creator>
      <pubDate>Sat, 21 Nov 2026 22:43:46 +0000</pubDate>
      <link>https://dev.to/superfunicular/is-an-old-nokia-android-phone-good-as-a-security-camera-which-models-stop-apps-with-the-screen-off-583g</link>
      <guid>https://dev.to/superfunicular/is-an-old-nokia-android-phone-good-as-a-security-camera-which-models-stop-apps-with-the-screen-off-583g</guid>
      <description>&lt;p&gt;Many people have an old Nokia Android phone in a drawer. A Nokia 6.1, a Nokia 3.1, a Nokia 1 that a family member used for two years. The question we get is simple: &lt;strong&gt;can that phone be a security camera that keeps recording with the screen off?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The short answer: &lt;strong&gt;on most Nokia phones running Android 9 (Pie) or newer, yes. On a few older models, there is a hidden app killer you must check first.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This matters more for Nokia than for any other brand, and the reason is a bit of history.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Nokia has a special story
&lt;/h2&gt;

&lt;p&gt;The volunteer site Don't Kill My App tracks how hard each phone brand stops background apps. Today it gives Nokia (HMD Global) a score of &lt;strong&gt;0&lt;/strong&gt; — the best score, the same as stock Android. Samsung, Xiaomi, OnePlus and Huawei all get 5, the worst.&lt;/p&gt;

&lt;p&gt;But it was not always like this. The site says it plainly:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"HMD Global/Nokia was the main reason this website came to exist. They had the most aggressive app killers preinstalled on their phones."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The old problem was a preinstalled app called &lt;strong&gt;Power saver&lt;/strong&gt; (package &lt;code&gt;com.evenwell.powersaving.g3&lt;/code&gt;), made by a third-party company, Evenwell. According to the site's (now struck-out) history, on Android Oreo and Pie Nokia phones it stopped background apps &lt;strong&gt;after about 20 minutes with the screen off&lt;/strong&gt;, and even apps you had excluded from battery optimization were stopped.&lt;/p&gt;

&lt;p&gt;For a camera phone, that is the worst case: you set it up, the screen goes dark, and twenty minutes later recording ends.&lt;/p&gt;

&lt;p&gt;The good news, again from the site:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"HMD Global claims to disable Evenwell powersaving apps on all devices running Android Pie or newer."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That change happened in &lt;strong&gt;August 2019&lt;/strong&gt;. So the first question for your old Nokia is not the model. It is the Android version.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Check the Android version
&lt;/h2&gt;

&lt;p&gt;Open &lt;strong&gt;Settings&lt;/strong&gt; and look for &lt;strong&gt;About phone&lt;/strong&gt; (on some versions it is inside &lt;strong&gt;System&lt;/strong&gt;). Find &lt;strong&gt;Android version&lt;/strong&gt;.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;What you see&lt;/th&gt;
&lt;th&gt;What it means for a camera&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Android 9 or newer, normal Nokia model&lt;/td&gt;
&lt;td&gt;Evenwell Power saver disabled by HMD. Treat it like stock Android. Go to Step 3.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"Android Go" or a Nokia 1&lt;/td&gt;
&lt;td&gt;Check for &lt;code&gt;com.evenwell.emm&lt;/code&gt;. Go to Step 2a.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Nokia 3.1 (US models TA-1049, TA-1063) or Nokia 5.1&lt;/td&gt;
&lt;td&gt;Check for DuraSpeed. Go to Step 2b.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Android 8.x on another Nokia model&lt;/td&gt;
&lt;td&gt;The old Power saver may still be there. Go to Step 2a.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;If the phone shows a system update, install it &lt;strong&gt;before&lt;/strong&gt; you start. On an old Nokia, the update is not just security — it may be the thing that removes the app killer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2a: Old Power saver (Evenwell) — the 20-minute killer
&lt;/h2&gt;

&lt;p&gt;Don't Kill My App lists two Evenwell packages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;com.evenwell.powersaving.g3&lt;/code&gt; — most Nokia models, &lt;strong&gt;disabled since 8/2019 on Pie or newer&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;com.evenwell.emm&lt;/code&gt; — the Nokia 1 on Android Go, which the site says is "&lt;strong&gt;probably still in the wild&lt;/strong&gt; since HMD only disabled Evenwell apps for Pie or greater"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To check and stop it without a computer:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go to &lt;strong&gt;Settings → Apps → See all apps&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Tap the &lt;strong&gt;menu in the top right → Show system&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Look for &lt;strong&gt;Power saver&lt;/strong&gt;. If it is there, open it and tap &lt;strong&gt;Force stop&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The site warns that it "will remain stopped for a while, but will restart itself eventually". So force-stop is a test tool, not a fix.&lt;/p&gt;

&lt;p&gt;The lasting fix needs a computer with adb (Android's developer tool). The site gives these commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;adb shell
pm disable-user com.evenwell.powersaving.g3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For the Nokia 1:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;adb shell
pm disable-user com.evenwell.emm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;disable-user&lt;/code&gt; turns the package off for your user. It does not delete anything. If you are not comfortable with adb, this is a good reason to choose a different old phone for camera duty instead of fighting this one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2b: DuraSpeed on the Nokia 3.1 and 5.1
&lt;/h2&gt;

&lt;p&gt;This is the harder one. On some MediaTek-based Nokias, the site says:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"There is no user-facing control, or whitelist; this Mediatek-developed task killer terminates all background apps without prejudice."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The listed models are the &lt;strong&gt;US Nokia 3.1 (TA-1049, TA-1063)&lt;/strong&gt; on a specific Pie build, and the &lt;strong&gt;Nokia 5.1&lt;/strong&gt;. The site marks it "&lt;strong&gt;still in the wild&lt;/strong&gt;".&lt;/p&gt;

&lt;p&gt;The fix on the site uses a hidden setting, &lt;code&gt;setting.duraspeed.enabled&lt;/code&gt;. DuraSpeed stops itself when that value is anything other than &lt;code&gt;1&lt;/code&gt;. But:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the setting can only be changed with adb, or by an app given the &lt;code&gt;WRITE_SECURE_SETTINGS&lt;/code&gt; permission through adb;&lt;/li&gt;
&lt;li&gt;it &lt;strong&gt;does not survive a reboot&lt;/strong&gt;, so an automation app (the site uses MacroDroid or Tasker) must set it again at every boot;&lt;/li&gt;
&lt;li&gt;the site also links "&lt;strong&gt;some reports that even this fix does not work&lt;/strong&gt;."&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Our honest advice: if your phone is a Nokia 3.1 or 5.1 with DuraSpeed, try the 30-minute test in Step 4 first. If it fails, use another phone as the camera. A camera you must re-fix after every power cut is not a camera you can trust.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Normal Android settings (all Nokias on Android 9+)
&lt;/h2&gt;

&lt;p&gt;Once the vendor layer is out of the way, a Nokia behaves like stock Android. That means the normal settings still apply:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Battery usage for the camera app: Unrestricted&lt;/strong&gt; (on older versions: &lt;strong&gt;Battery optimization → Not optimized&lt;/strong&gt;). Find it in Settings → Apps → the app → Battery.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Battery Saver off&lt;/strong&gt;, and not set to turn on by itself. A phone on a charger does not need it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Adaptive Battery&lt;/strong&gt;: if the camera still stops, try turning it off on the camera phone. It is a phone only for the camera, so you lose nothing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Do not swipe the camera app away&lt;/strong&gt; in the recent apps screen.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Android's own Doze mode is not the enemy here. A camera app that runs a foreground service (the notification you see while it records) is the normal, supported way to keep working with the screen off. We explained this in &lt;a href="https://dev.to/superfunicular/why-does-my-android-camera-stop-recording-when-the-screen-turns-off-doze-workmanager-and-the-1a5d"&gt;Why Does My Android Camera Stop Recording When the Screen Turns Off?&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: The 30-minute test (then overnight)
&lt;/h2&gt;

&lt;p&gt;The old Evenwell behaviour was a cut at about 20 minutes with the screen off. So a 10-minute test is &lt;strong&gt;not enough&lt;/strong&gt; on a Nokia. Do this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Charge the phone, plug it in, start recording.&lt;/li&gt;
&lt;li&gt;Turn the screen off. Note the time.&lt;/li&gt;
&lt;li&gt;Wait &lt;strong&gt;30 minutes&lt;/strong&gt;. Do not touch the phone.&lt;/li&gt;
&lt;li&gt;Open the recordings. Is there one continuous recording (or clean segments) covering the full 30 minutes?&lt;/li&gt;
&lt;li&gt;If yes, repeat overnight. Check the morning: does the footage reach the morning, or stop at some time in the night?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;How to read the result:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Result&lt;/th&gt;
&lt;th&gt;Likely cause&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Stops near 20 minutes&lt;/td&gt;
&lt;td&gt;A vendor killer (Step 2a or 2b) is still active&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Stops at a random time at night&lt;/td&gt;
&lt;td&gt;Memory pressure, Battery Saver, or Adaptive Battery&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Stops at the same time every night&lt;/td&gt;
&lt;td&gt;A scheduled restart or a power issue (check the charger)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Full night recorded&lt;/td&gt;
&lt;td&gt;Your Nokia is ready&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Does this work without internet?
&lt;/h2&gt;

&lt;p&gt;Yes. Recording with the screen off happens on the phone and saves to the phone's storage. It does not need mobile data, Wi-Fi internet, or a cloud account. None of the Nokia steps above need internet either — except installing a system update, which you can do once at home before setting up.&lt;/p&gt;

&lt;p&gt;If you use the live view in a browser, that runs over your own Wi-Fi network (the phone and the viewer on the same router). The router does not need an internet connection for that. YouTube Live, of course, does need internet.&lt;/p&gt;

&lt;h2&gt;
  
  
  Is an old Nokia a good choice overall?
&lt;/h2&gt;

&lt;p&gt;For most Nokias on Android 9 or newer, it is a good choice. The battery-killing reputation is from 2018–2019, and the site's own score is now 0.&lt;/p&gt;

&lt;p&gt;A few practical points still apply to any old phone:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Battery health&lt;/strong&gt;: an old battery can swell or fail. Look at the back cover. If it lifts, do not use it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Storage&lt;/strong&gt;: older budget Nokias often have small storage. Use a microSD card if the phone has a slot, and test it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Memory&lt;/strong&gt;: on 1–2 GB RAM phones, Android may stop apps to free memory, whatever the brand. Use the phone only for the camera.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Charger&lt;/strong&gt;: a weak charger can make the battery drop even while plugged in.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Other brands
&lt;/h2&gt;

&lt;p&gt;If your drawer phone is not a Nokia:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;OnePlus:&lt;/strong&gt; &lt;a href="https://dev.to/superfunicular/why-does-my-oneplus-phone-stop-the-camera-app-with-the-screen-off-battery-optimization-that-resets-3128"&gt;Why Does My OnePlus Phone Stop the Camera App With the Screen Off?&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Samsung:&lt;/strong&gt; &lt;a href="https://dev.to/superfunicular/why-does-my-samsung-phone-camera-stop-recording-at-night-auto-restart-the-30-battery-rule-and-2nhh"&gt;Why Does My Samsung Phone Camera Stop Recording at Night?&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Redmi, POCO or Xiaomi:&lt;/strong&gt; &lt;a href="https://dev.to/superfunicular/why-does-my-redmi-poco-or-xiaomi-phone-stop-the-camera-app-with-the-screen-off-autostart-battery-29kg"&gt;Why Does My Redmi, POCO or Xiaomi Phone Stop the Camera App With the Screen Off?&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tecno, Infinix or itel:&lt;/strong&gt; &lt;a href="https://dev.to/superfunicular/why-does-my-tecno-infinix-or-itel-phone-stop-the-camera-app-with-the-screen-off-phone-master-fa4"&gt;Why Does My Tecno, Infinix or itel Phone Stop the Camera App With the Screen Off?&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Motorola:&lt;/strong&gt; &lt;a href="https://dev.to/superfunicular/why-does-my-motorola-phone-stop-the-camera-app-with-the-screen-off-unrestricted-battery-usage-2apn"&gt;Why Does My Motorola Phone Stop the Camera App With the Screen Off?&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;New to this? Start with &lt;a href="https://dev.to/superfunicular/turn-an-old-android-phone-into-a-screen-off-security-camera-no-cloud-lan-only-5cll"&gt;Turn an old Android phone into a screen-off security camera (no cloud, LAN-only)&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Sources
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Don't Kill My App — &lt;a href="https://dontkillmyapp.com/hmd-global" rel="noopener noreferrer"&gt;Nokia / HMD Global&lt;/a&gt; (page dated 9 June 2026): score, the 8/2019 Evenwell disable, the three mechanisms and model numbers, Power saver force-stop steps, adb &lt;code&gt;disable-user&lt;/code&gt; commands, DuraSpeed &lt;code&gt;setting.duraspeed.enabled&lt;/code&gt; workaround and its limits. Vendor scores read from the site's list on 21 November 2026.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Don't Kill My App is a volunteer project, not official Nokia or HMD documentation. Menus differ by model and software version — which is why the test matters more than the menu.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Background Camera RemoteStream&lt;/strong&gt; turns an Android phone into a screen-off camera: it records with the screen off and keeps recordings on the phone, with no cloud account needed. Its Pro tier adds a live browser view over your own Wi-Fi and YouTube Live streaming; check the Play listing for what is free and what is Pro, and whether it installs on your phone.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Google Play: &lt;a href="https://play.google.com/store/apps/details?id=com.superfunicular.digicam" rel="noopener noreferrer"&gt;https://play.google.com/store/apps/details?id=com.superfunicular.digicam&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Website: &lt;a href="https://superfunicular.com" rel="noopener noreferrer"&gt;https://superfunicular.com&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>android</category>
      <category>security</category>
      <category>tutorial</category>
      <category>mobile</category>
    </item>
    <item>
      <title>Four Parallel Clip Encodes, One Failed, and Bash wait Still Returned 0</title>
      <dc:creator>Super Funicular</dc:creator>
      <pubDate>Wed, 18 Nov 2026 13:58:06 +0000</pubDate>
      <link>https://dev.to/superfunicular/four-parallel-clip-encodes-one-failed-and-bash-wait-still-returned-0-4ie2</link>
      <guid>https://dev.to/superfunicular/four-parallel-clip-encodes-one-failed-and-bash-wait-still-returned-0-4ie2</guid>
      <description>&lt;p&gt;A nightly script encodes four camera clips at once by putting each encoder in the background and then calling &lt;code&gt;wait&lt;/code&gt;. One of the four fails. The script exits with status 0, nothing that checks its exit status notices, and the broken clip turns up whenever someone next opens it.&lt;/p&gt;

&lt;p&gt;The four encoders here are a stand-in script that sleeps and then exits with whatever code it is given, so a failure can be planted on purpose:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="c"&gt;# Stand-in for an encoder: fake_encode.sh NAME SECONDS EXIT_CODE&lt;/span&gt;
sleep &lt;span class="s2"&gt;"$2"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"finished $1, exit $3"&lt;/span&gt;
&lt;span class="nb"&gt;exit&lt;/span&gt; &lt;span class="s2"&gt;"$3"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="c"&gt;# Four encodes in parallel. c.mp4 fails with exit 1.&lt;/span&gt;
./fake_encode.sh a.mp4 0.4 0 &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;
./fake_encode.sh b.mp4 0.1 0 &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;
./fake_encode.sh c.mp4 0.3 1 &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;
./fake_encode.sh d.mp4 0.2 0 &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;
&lt;span class="nb"&gt;wait&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"wait returned $?"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;finished b.mp4, exit 0
finished d.mp4, exit 0
finished c.mp4, exit 1
finished a.mp4, exit 0
wait returned 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;c.mp4&lt;/code&gt; exited 1 and said so. &lt;code&gt;wait&lt;/code&gt; returned 0 anyway.&lt;/p&gt;

&lt;p&gt;Disclosure: I make an Android camera app. Nothing below uses its code or describes how it records or processes anything. The encoder is the fake one above, the clips are only names, and every output is pasted from the scripts shown. Versions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GNU bash, version 5.1.16(1)-release (aarch64-unknown-linux-gnu)
Linux 6.8.0-138-generic
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What the manual says plain wait returns
&lt;/h2&gt;

&lt;p&gt;The Bash manual is direct about this case. With no arguments, &lt;code&gt;wait&lt;/code&gt; "waits for all running background jobs and the last-executed process substitution, if its process id is the same as $!, and the return status is zero".&lt;/p&gt;

&lt;p&gt;So the 0 is not a lucky race or a bug. Plain &lt;code&gt;wait&lt;/code&gt; is a barrier. It holds the script until every background job is done, and it reports nothing about how any of them ended. The exit codes are thrown away unless something else asks for them.&lt;/p&gt;

&lt;p&gt;That is easy to miss because the form with an argument behaves the way people expect from plain &lt;code&gt;wait&lt;/code&gt;. The first sentence of the same entry: "Wait until the child process specified by each id exits and return the exit status of the last id." The status only comes back when you name the job.&lt;/p&gt;

&lt;h2&gt;
  
  
  set -e does not catch it either
&lt;/h2&gt;

&lt;p&gt;A common reflex is to put &lt;code&gt;set -e&lt;/code&gt; at the top and assume any failure will stop the script. I ran two versions with &lt;code&gt;set -e&lt;/code&gt;, one with plain &lt;code&gt;wait&lt;/code&gt; and one that waits on the failing job by PID:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; -e
./fake_encode.sh a.mp4 0.2 0 &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;
./fake_encode.sh c.mp4 0.1 1 &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;
&lt;span class="nb"&gt;wait&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"set -e did not stop the script; wait returned $?"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; -e
./fake_encode.sh a.mp4 0.2 0 &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="nv"&gt;pa&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$!&lt;/span&gt;
./fake_encode.sh c.mp4 0.1 1 &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="nv"&gt;pc&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$!&lt;/span&gt;
&lt;span class="nb"&gt;wait&lt;/span&gt; &lt;span class="s2"&gt;"$pc"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"this line never prints"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
./set_e.sh&lt;span class="o"&gt;;&lt;/span&gt;     &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"set_e.sh exit status: $?"&lt;/span&gt;
./set_e_pid.sh&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"set_e_pid.sh exit status: $?"&lt;/span&gt;
sleep 0.3   &lt;span class="c"&gt;# let the orphaned a.mp4 job finish before the next command&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;finished c.mp4, exit 1
finished a.mp4, exit 0
set -e did not stop the script; wait returned 0
set_e.sh exit status: 0
finished c.mp4, exit 1
set_e_pid.sh exit status: 1
finished a.mp4, exit 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three things show up in that output:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;With plain &lt;code&gt;wait&lt;/code&gt;, &lt;code&gt;set -e&lt;/code&gt; did not fire.&lt;/strong&gt; The script printed its last line and exited 0. Plain &lt;code&gt;wait&lt;/code&gt; returned 0, and the failed job did not produce a nonzero status anywhere in the script itself.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Waiting on &lt;code&gt;$pc&lt;/code&gt; by PID, &lt;code&gt;set -e&lt;/code&gt; did fire.&lt;/strong&gt; That &lt;code&gt;wait&lt;/code&gt; returned 1, &lt;code&gt;set -e&lt;/code&gt; treated it like any other failing command, and the script exited 1 before its last line.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The other job kept running after the script exited.&lt;/strong&gt; &lt;code&gt;finished a.mp4&lt;/code&gt; printed after &lt;code&gt;set_e_pid.sh exit status: 1&lt;/code&gt;. Exiting early does not stop background jobs. If the job is an encoder writing to a file, that file is still being written after the script has reported failure.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The last point matters if the script does cleanup at the end. A script that stops at the first failed &lt;code&gt;wait&lt;/code&gt; and leaves a sibling running can have a half-written clip next to a finished one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Keep every PID and wait for each one
&lt;/h2&gt;

&lt;p&gt;The fix that needs nothing beyond plain Bash is to remember each PID as the job starts, then wait for them one at a time and collect the failures:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="c"&gt;# Keep every PID, then wait for each one by PID.&lt;/span&gt;
&lt;span class="kd"&gt;declare&lt;/span&gt; -A clip
./fake_encode.sh a.mp4 0.4 0 &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; clip&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$!&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;a.mp4
./fake_encode.sh b.mp4 0.1 0 &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; clip&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$!&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;b.mp4
./fake_encode.sh c.mp4 0.3 1 &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; clip&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$!&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;c.mp4
./fake_encode.sh d.mp4 0.2 0 &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; clip&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$!&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;d.mp4
&lt;span class="nv"&gt;failed&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; pid &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="s2"&gt;"${!clip[@]}"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="nb"&gt;wait&lt;/span&gt; &lt;span class="s2"&gt;"$pid"&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; failed+=&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"${clip[$pid]}"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;${#failed[@]}&lt;/span&gt; &lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"failed: ${failed[*]}"&lt;/span&gt;
  &lt;span class="nb"&gt;exit&lt;/span&gt; 1
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"all encodes succeeded"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;finished b.mp4, exit 0
finished d.mp4, exit 0
finished c.mp4, exit 1
finished a.mp4, exit 0
failed: c.mp4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;$!&lt;/code&gt; holds the PID of the job just started, so saving it on the same line keeps the PID and the clip name together. The loop then waits for every PID, even after one has failed, so the script does not exit while an encode is still running. It ends by naming the failed clip and returning 1, which is what cron and anything else downstream needs to see.&lt;/p&gt;

&lt;p&gt;The order the loop waits in does not matter. If it waits for &lt;code&gt;a.mp4&lt;/code&gt; first and &lt;code&gt;c.mp4&lt;/code&gt; has already finished, the result of &lt;code&gt;c.mp4&lt;/code&gt; is still there when the loop gets to it.&lt;/p&gt;

&lt;h2&gt;
  
  
  A job that already ended still has a status
&lt;/h2&gt;

&lt;p&gt;That last claim is worth checking, because it is what makes the PID loop safe. Here the job exits with 3 immediately and nobody waits for it until a second later:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="c"&gt;# The job exits with 3 long before anyone waits for it.&lt;/span&gt;
./fake_encode.sh x.mp4 0 3 &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /dev/null &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="nv"&gt;p&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$!&lt;/span&gt;
sleep 1
&lt;span class="nb"&gt;wait&lt;/span&gt; &lt;span class="s2"&gt;"$p"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"wait on a job that ended a second ago: $?"&lt;/span&gt;
&lt;span class="nb"&gt;wait&lt;/span&gt; &lt;span class="s2"&gt;"$p"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"the same PID a second time: $?"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;wait on a job that ended a second ago: 3
the same PID a second time: 3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The status was still there after the job ended, and in this Bash it was still there on a second &lt;code&gt;wait&lt;/code&gt; for the same PID. I would not build on the second result. The point that matters is the first one: a script can start its jobs, do other work, and collect the results afterwards without losing any.&lt;/p&gt;

&lt;h2&gt;
  
  
  wait -n for a limit on how many run at once
&lt;/h2&gt;

&lt;p&gt;Four encodes at once is fine for four short clips. For a folder of a hundred, the usual goal is to keep a fixed number running and start the next one whenever one finishes. &lt;code&gt;wait -n&lt;/code&gt; does that part. With no PIDs given, the manual says it waits for any job or process substitution "to complete and returns its exit status".&lt;/p&gt;

&lt;p&gt;&lt;code&gt;wait -n&lt;/code&gt; on its own says how a job ended but not which job it was. The &lt;code&gt;-p&lt;/code&gt; option fills that gap by putting the PID in a variable, and the manual is clear about where it applies: "This is useful only when used with the -n option."&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="c"&gt;# At most two encodes at once. wait -n returns as soon as any one finishes;&lt;/span&gt;
&lt;span class="c"&gt;# -p names the PID it is reporting on.&lt;/span&gt;
&lt;span class="kd"&gt;declare&lt;/span&gt; -A clip
&lt;span class="nv"&gt;running&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0 &lt;span class="nv"&gt;fails&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0
reap&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;local&lt;/span&gt; who rc
  &lt;span class="nb"&gt;wait&lt;/span&gt; -n -p who&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nv"&gt;rc&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$?&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"reaped ${clip[$who]}: $rc"&lt;/span&gt;
  &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt; rc != 0 &lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nv"&gt;fails&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;fails + 1&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
  &lt;span class="nv"&gt;running&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;running - 1&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; spec &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="s2"&gt;"a.mp4 0.4 0"&lt;/span&gt; &lt;span class="s2"&gt;"b.mp4 0.1 0"&lt;/span&gt; &lt;span class="s2"&gt;"c.mp4 0.2 1"&lt;/span&gt; &lt;span class="s2"&gt;"d.mp4 0.2 0"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="nb"&gt;set&lt;/span&gt; -- &lt;span class="nv"&gt;$spec&lt;/span&gt;
  &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt; running &lt;span class="o"&gt;==&lt;/span&gt; 2 &lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; reap
  ./fake_encode.sh &lt;span class="s2"&gt;"$1"&lt;/span&gt; &lt;span class="s2"&gt;"$2"&lt;/span&gt; &lt;span class="s2"&gt;"$3"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /dev/null &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; clip&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$!&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;
  &lt;span class="nv"&gt;running&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;running + 1&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt; running &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; 0 &lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; reap&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;done&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"failures: $fails"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;reaped b.mp4: 0
reaped c.mp4: 1
reaped a.mp4: 0
reaped d.mp4: 0
failures: 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two encodes run at a time. &lt;code&gt;b.mp4&lt;/code&gt; finished first, so &lt;code&gt;c.mp4&lt;/code&gt; started in its place. &lt;code&gt;c.mp4&lt;/code&gt; finished next, and failed, so &lt;code&gt;d.mp4&lt;/code&gt; started. The script reports the failure by clip name and still waits for the last two.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;while&lt;/code&gt; loop at the end drains whatever is still running. Without it the script would leave the last jobs unreaped, which is the same problem as the plain &lt;code&gt;wait&lt;/code&gt; version.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two status values worth knowing on sight
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;127.&lt;/strong&gt; The manual says &lt;code&gt;wait -n&lt;/code&gt; returns 127 "if no arguments are supplied and the shell has no unwaited-for children", and that a PID which is not a child of the shell also gives 127:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="nb"&gt;wait&lt;/span&gt; -n&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"wait -n with no children: $?"&lt;/span&gt;
&lt;span class="nb"&gt;wait&lt;/span&gt; 99999&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"wait on a PID that is not our child: $?"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;wait -n with no children: 127
./nothing.sh: line 3: wait: pid 99999 is not a child of this shell
wait on a PID that is not our child: 127
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A drain loop that counts 127 as one more failure will report a failure that did not happen. The loop above avoids that by counting the jobs it started, so it does not call &lt;code&gt;wait -n&lt;/code&gt; with nothing left.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;128 and up.&lt;/strong&gt; A job stopped by a signal comes back with a status above 128, and &lt;code&gt;kill -l&lt;/code&gt; turns that status back into a signal name:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="c"&gt;# A long job that gets stopped with the default signal of kill (SIGTERM).&lt;/span&gt;
sleep 30 &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="nv"&gt;p&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$!&lt;/span&gt;
sleep 0.2
&lt;span class="nb"&gt;kill&lt;/span&gt; &lt;span class="s2"&gt;"$p"&lt;/span&gt;
&lt;span class="nb"&gt;wait&lt;/span&gt; &lt;span class="s2"&gt;"$p"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nv"&gt;rc&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$?&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"status $rc, signal $(kill -l "&lt;/span&gt;&lt;span class="nv"&gt;$rc&lt;/span&gt;&lt;span class="s2"&gt;")"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;status 143, signal TERM
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;143 is SIGTERM, the signal &lt;code&gt;kill&lt;/code&gt; sends by default. If an encode was killed by a timeout, a supervisor or a person at a terminal, this is the status the script sees, and it is worth logging as a stop rather than a failure inside the encoder.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to change in a script like this
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Replace a bare &lt;code&gt;wait&lt;/code&gt; at the end of a parallel section with a loop over saved PIDs, or with a &lt;code&gt;wait -n&lt;/code&gt; loop if the number of jobs running at once needs a limit.&lt;/li&gt;
&lt;li&gt;Name the failed job in the output. A script that only exits 1 still leaves someone guessing which clip broke.&lt;/li&gt;
&lt;li&gt;Wait for every job before exiting, even after a failure, so nothing is still writing when the script reports.&lt;/li&gt;
&lt;li&gt;Treat 127 from &lt;code&gt;wait&lt;/code&gt; as a script bug, not an encode failure, and a status above 128 as a stop by signal.&lt;/li&gt;
&lt;li&gt;Do not count on &lt;code&gt;set -e&lt;/code&gt; to notice a background job. It only acts on a status that reaches the script, and plain &lt;code&gt;wait&lt;/code&gt; returns 0.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Things I did not test
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Other Bash versions.&lt;/strong&gt; I ran 5.1. The quotes come from the current online manual. Everything I ran matched it, but I did not run a newer or older Bash.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Other shells.&lt;/strong&gt; &lt;code&gt;sh&lt;/code&gt;, &lt;code&gt;dash&lt;/code&gt;, &lt;code&gt;zsh&lt;/code&gt; and others have their own &lt;code&gt;wait&lt;/code&gt;. I did not test any of them, and the &lt;code&gt;-n&lt;/code&gt; and &lt;code&gt;-p&lt;/code&gt; options above are taken from the Bash manual only.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Job control.&lt;/strong&gt; These are scripts, where job control is off by default. The &lt;code&gt;-f&lt;/code&gt; option and job specs like &lt;code&gt;%1&lt;/code&gt; behave differently with job control on, and I did not test them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Real encoders.&lt;/strong&gt; The jobs here sleep and exit. A real encoder may trap signals or exit with codes of its own, so check what it returns before reading meaning into a status.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Sources.&lt;/strong&gt; Quotes are from the GNU Bash Reference Manual page &lt;a href="https://www.gnu.org/software/bash/manual/html_node/Job-Control-Builtins.html" rel="noopener noreferrer"&gt;Job Control Builtins&lt;/a&gt; (the &lt;code&gt;wait&lt;/code&gt; entry). Outputs are pasted unedited from the scripts above.&lt;/p&gt;

&lt;p&gt;If you want an old Android phone recording in the background so there are clips for a job like this to process, the app I make is &lt;a href="https://play.google.com/store/apps/details?id=com.superfunicular.digicam" rel="noopener noreferrer"&gt;Background Camera RemoteStream on Google Play&lt;/a&gt;. Nothing above depends on it.&lt;/p&gt;

&lt;p&gt;A bare &lt;code&gt;wait&lt;/code&gt; returns 0 however its jobs ended, so save each &lt;code&gt;$!&lt;/code&gt; and wait on every PID, or loop on &lt;code&gt;wait -n -p&lt;/code&gt; when the count needs a limit, and read a 127 as a bug in the script rather than a failed clip.&lt;/p&gt;

</description>
      <category>bash</category>
      <category>linux</category>
      <category>devops</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>The Night the Clocks Went Back, Three Pairs of Camera Clips Came Out of the Zip With the Same Time</title>
      <dc:creator>Super Funicular</dc:creator>
      <pubDate>Wed, 18 Nov 2026 08:59:23 +0000</pubDate>
      <link>https://dev.to/superfunicular/the-night-the-clocks-went-back-three-pairs-of-camera-clips-came-out-of-the-zip-with-the-same-time-3h0n</link>
      <guid>https://dev.to/superfunicular/the-night-the-clocks-went-back-three-pairs-of-camera-clips-came-out-of-the-zip-with-the-same-time-3h0n</guid>
      <description>&lt;p&gt;An old phone recorded through the night of 1 November 2026, when New York clocks went from 01:59 EDT back to 01:00 EST. In the morning a script packed the night's clips into a zip with Python's &lt;code&gt;zipfile&lt;/code&gt; and a second script, on the same machine, in the same time zone, unpacked them. Six of the eight clips came out paired up: two clips recorded an hour apart, stamped with exactly the same time.&lt;/p&gt;

&lt;p&gt;This follows my earlier test, &lt;a href="https://dev.to/superfunicular/pythons-zipfile-dated-every-extracted-camera-clip-as-just-now-and-unzip-brought-them-back-five-eec"&gt;Python's zipfile Dated Every Extracted Camera Clip as Just Now&lt;/a&gt;, which moved a zip between time zones and listed daylight saving as untested. No zone change is needed this time. The repeated hour does it on one machine.&lt;/p&gt;

&lt;h2&gt;
  
  
  The night
&lt;/h2&gt;

&lt;p&gt;Eight fake clips, 20 minutes apart, from 04:40 UTC to 07:00 UTC. In New York that is 00:40 EDT to 02:00 EST, and the hour from 01:00 to 01:59 happens twice. The script sets &lt;code&gt;TZ=America/New_York&lt;/code&gt; itself, so it gives the same result anywhere. Python 3.10.12, Zip 3.0, UnZip 6.00, Linux.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cam1_00.mp4 04:40Z 00:40 EDT
cam1_01.mp4 05:00Z 01:00 EDT
cam1_02.mp4 05:20Z 01:20 EDT
cam1_03.mp4 05:40Z 01:40 EDT
cam1_04.mp4 06:00Z 01:00 EST
cam1_05.mp4 06:20Z 01:20 EST
cam1_06.mp4 06:40Z 01:40 EST
cam1_07.mp4 07:00Z 02:00 EST
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What zipfile writes down
&lt;/h2&gt;

&lt;p&gt;A zip entry's main timestamp is a DOS date and wall-clock time with no zone and no daylight-saving flag. Here is what &lt;code&gt;zipfile&lt;/code&gt; stored:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cam1_00.mp4 2026-11-01 00:40:00
cam1_01.mp4 2026-11-01 01:00:00
cam1_02.mp4 2026-11-01 01:20:00
cam1_03.mp4 2026-11-01 01:40:00
cam1_04.mp4 2026-11-01 01:00:00
cam1_05.mp4 2026-11-01 01:20:00
cam1_06.mp4 2026-11-01 01:40:00
cam1_07.mp4 2026-11-01 02:00:00
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;cam1_01&lt;/code&gt; and &lt;code&gt;cam1_04&lt;/code&gt; were recorded an hour apart and the archive holds the same time for both. Same for 02/05 and 03/06. Nothing about the order survives in the time field, so no reader can tell them apart.&lt;/p&gt;

&lt;h2&gt;
  
  
  Four ways to pack, one way to fail
&lt;/h2&gt;

&lt;p&gt;The full script is below. It packs the clips four ways, unpacks each on the same New York machine, and prints each clip's time minus the original, in seconds, clips 00 to 07:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;delta in seconds, clips 00..07, written and read in New York:
zipfile write, unzip read          +0 +3600 +3600 +3600 +0 +0 +0 +0
zip command, unzip read            +0 +0 +0 +0 +0 +0 +0 +0
zipfile + UT field, unzip read     +0 +0 +0 +0 +0 +0 +0 +0
tarfile write, tarfile read        +0 +0 +0 +0 +0 +0 +0 +0
zipfile read + date_time in NY     +0 +0 +0 +0 -3600 -3600 -3600 +0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;zipfile&lt;/code&gt; write, &lt;code&gt;unzip&lt;/code&gt; read:&lt;/strong&gt; &lt;code&gt;unzip&lt;/code&gt; read the three repeated wall times as the second 01:xx (EST), so the three EDT clips came back an hour late.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;zipfile&lt;/code&gt; read, times put back from &lt;code&gt;date_time&lt;/code&gt; with the zone passed in:&lt;/strong&gt; this is the repair from the earlier post. Python's &lt;code&gt;datetime&lt;/code&gt; took the first 01:xx (EDT), so the three EST clips came back an hour early. Passing the right zone name does not help when the wall time itself is ambiguous.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;zip&lt;/code&gt; command:&lt;/strong&gt; exact. It writes a UT extra field holding the time as UTC seconds, and &lt;code&gt;unzip&lt;/code&gt; prefers that over the DOS time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;tarfile&lt;/code&gt;:&lt;/strong&gt; exact. Tar stores UTC seconds.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;zipfile&lt;/code&gt; plus a hand-built UT field:&lt;/strong&gt; exact. This is the write-side fix that dev.to reader &lt;a href="https://dev.to/acemeridian"&gt;acemeridian&lt;/a&gt; posted under the earlier article, after rerunning it on Python 3.14.4. Build the &lt;code&gt;ZipInfo&lt;/code&gt; yourself and attach the same UT field the &lt;code&gt;zip&lt;/code&gt; command writes. I copied the idea into the script below.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The two broken readers fail in opposite directions. Which half of the night goes wrong depends on the tool, not on the clips.&lt;/p&gt;

&lt;p&gt;Here are the clips that end up sharing a time after &lt;code&gt;unzip&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;After unzip of the zipfile-made zip, clips sharing one time:
  01:00 EST ['cam1_01.mp4', 'cam1_04.mp4']
  01:20 EST ['cam1_02.mp4', 'cam1_05.mp4']
  01:40 EST ['cam1_03.mp4', 'cam1_06.mp4']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A viewer sorted by date now interleaves the first and second 01:00 hour. A "find what happened at 01:20" search returns two clips, and only one of them was recorded then. A sync tool that compares times sees six changed files.&lt;/p&gt;

&lt;h2&gt;
  
  
  The script
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Clips recorded across the night US clocks went back (1 Nov 2026, New York).&lt;/span&gt;
&lt;span class="c1"&gt;# Zip them four ways on a New York machine, unpack on the same machine,&lt;/span&gt;
&lt;span class="c1"&gt;# and compare each clip's time with the original.&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;shutil&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;struct&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;subprocess&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tarfile&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;zipfile&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timezone&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;zoneinfo&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;ZoneInfo&lt;/span&gt;

&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"TZ"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"America/New_York"&lt;/span&gt;
&lt;span class="no"&gt;NY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ZoneInfo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"America/New_York"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;shutil&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;rmtree&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"clips"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ignore_errors&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;makedirs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"clips"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;start&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2026&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;11&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tzinfo&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;timezone&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;utc&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;timestamp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;names&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;                       &lt;span class="c1"&gt;# every 20 min, 04:40Z .. 07:00Z&lt;/span&gt;
    &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;start&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;1200&lt;/span&gt;
    &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"cam1_%02d.mp4"&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;
    &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"clips/"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"wb"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;urandom&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;512&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;utime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"clips/"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;names&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;loc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fromtimestamp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;NY&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fromtimestamp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timezone&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;utc&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;strftime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"%H:%MZ"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="n"&gt;loc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;strftime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"%H:%M %Z"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;orig&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"clips/"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;st_mtime&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;report&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;label&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;folder&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;folder&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;st_mtime&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nf"&gt;orig&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;names&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"%-34s %s"&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;label&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;" "&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"%+d"&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# 1. zipfile write, unzip read&lt;/span&gt;
&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;zipfile&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ZipFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"py.zip"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"w"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;z&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;names&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;z&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"clips/"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# 2. zip command&lt;/span&gt;
&lt;span class="n"&gt;subprocess&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"cd clips &amp;amp;&amp;amp; zip -q ../cli.zip "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;" "&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;names&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;shell&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;check&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# 3. zipfile with a UT extra field written by hand&lt;/span&gt;
&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;zipfile&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ZipFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"py_ut.zip"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"w"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;z&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;names&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;zi&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;zipfile&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ZipInfo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;from_file&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"clips/"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;zi&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;extra&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;struct&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"&amp;lt;HHBl"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x5455&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;orig&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"clips/"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"rb"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;z&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;zi&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"w"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;shutil&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;copyfileobj&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# 4. tar&lt;/span&gt;
&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;tarfile&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"clips.tar"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"w"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;names&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"clips/"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"\ndelta in seconds, clips 00..07, written and read in New York:"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;z&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"py"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"cli"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"py_ut"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;shutil&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;rmtree&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"o_"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;z&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ignore_errors&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;subprocess&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"unzip"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"-q"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;z&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;".zip"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"-d"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"o_"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;z&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;check&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;report&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"py"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"zipfile write, unzip read"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"cli"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"zip command, unzip read"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="s2"&gt;"py_ut"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"zipfile + UT field, unzip read"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;z&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"o_"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;z&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;shutil&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;rmtree&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"o_tar"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ignore_errors&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;tarfile&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"clips.tar"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;extractall&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"o_tar"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;report&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"tarfile write, tarfile read"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"o_tar"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# 5. zipfile read, times put back from date_time with the right zone name&lt;/span&gt;
&lt;span class="n"&gt;shutil&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;rmtree&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"o_fix"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ignore_errors&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;zipfile&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ZipFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"py.zip"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;z&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;z&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;extractall&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"o_fix"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;info&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;z&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;infolist&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;info&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;date_time&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tzinfo&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;NY&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;timestamp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;utime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"o_fix/"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;info&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;filename&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;report&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"zipfile read + date_time in NY"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"o_fix"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"\nDOS times stored by zipfile:"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;zipfile&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ZipFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"py.zip"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;z&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;z&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;infolist&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;" "&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;filename&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"%04d-%02d-%02d %02d:%02d:%02d"&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;date_time&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"\nAfter unzip of the zipfile-made zip, clips sharing one time:"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;seen&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;names&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;seen&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setdefault&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"o_py/"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;st_mtime&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ns&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;seen&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;items&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ns&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;" "&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fromtimestamp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;NY&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;strftime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"%H:%M %Z"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ns&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every output block above was printed by this script, unedited. The clip times sit on whole minutes, so the two-second rounding from the earlier post does not show up here.&lt;/p&gt;

&lt;h2&gt;
  
  
  When this bites a camera setup
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Any recorder in a zone with daylight saving&lt;/strong&gt; writes an ambiguous hour once a year, in autumn. In spring the skipped hour cannot be recorded at all, so that change does not cause this problem.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Overnight recording is the worst case.&lt;/strong&gt; The repeated hour is 01:00 to 01:59 in the US and 02:00 to 02:59 in central Europe, the hours a home camera is most likely to be the only thing awake.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A zip made the next morning&lt;/strong&gt; carries the problem forward, even if it never leaves the machine.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What I would do
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Check what wrote the archive.&lt;/strong&gt; &lt;code&gt;zipinfo -v archive.zip one_clip.mp4&lt;/code&gt; shows a &lt;code&gt;UT extra field modtime ... UTC&lt;/code&gt; line when the time is stored safely. No such line means the time is the DOS time only.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;When packing with Python, attach the UT field&lt;/strong&gt; (step 3 in the script), or use &lt;code&gt;tarfile&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Put the recording time in the filename in UTC or with an offset&lt;/strong&gt;, for example &lt;code&gt;cam1_20261101T0500Z.mp4&lt;/code&gt; or &lt;code&gt;cam1_2026-11-01T01-00-00-0400.mp4&lt;/code&gt;. A filename survives every archive format, copy tool and cloud upload. A modification time does not.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Don't try to repair it afterwards.&lt;/strong&gt; Once two clips share a DOS time, no zone setting brings the order back. The information is gone from the archive.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Not tested
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Only US Eastern time. Other zones with a repeated hour should behave the same way, but I ran only this one.&lt;/li&gt;
&lt;li&gt;Only Info-ZIP &lt;code&gt;unzip&lt;/code&gt; and Python on Linux. Windows Explorer, macOS Archive Utility and phone file managers are unchecked.&lt;/li&gt;
&lt;li&gt;Only Python 3.10.12 for writing. acemeridian's 3.14.4 run of the earlier tests matched 3.10 on every point he checked, but I did not rerun this test on 3.14.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you want an old Android phone recording in the background overnight, the app I make is &lt;a href="https://play.google.com/store/apps/details?id=com.superfunicular.digicam" rel="noopener noreferrer"&gt;Background Camera RemoteStream on Google Play&lt;/a&gt;. Nothing above depends on it.&lt;/p&gt;

&lt;p&gt;A zip's DOS time has no zone and no daylight-saving flag, so the hour the clocks go back is stored twice, with nothing to tell the two apart. Store UTC: use the UT field, tar, or the filename.&lt;/p&gt;

</description>
      <category>python</category>
      <category>linux</category>
      <category>datetime</category>
      <category>homelab</category>
    </item>
    <item>
      <title>Why Does My OnePlus Phone Stop the Camera App With the Screen Off? Battery Optimization That Resets Itself, Sleep Standby and Recents Lock</title>
      <dc:creator>Super Funicular</dc:creator>
      <pubDate>Wed, 18 Nov 2026 08:11:36 +0000</pubDate>
      <link>https://dev.to/superfunicular/why-does-my-oneplus-phone-stop-the-camera-app-with-the-screen-off-battery-optimization-that-resets-3128</link>
      <guid>https://dev.to/superfunicular/why-does-my-oneplus-phone-stop-the-camera-app-with-the-screen-off-battery-optimization-that-resets-3128</guid>
      <description>&lt;p&gt;You set up an old OnePlus phone as a camera. It worked on the first night. You fixed the battery settings, the camera app recorded with the screen off, and the live view loaded on your laptop.&lt;/p&gt;

&lt;p&gt;A few days later it stops again. You open Settings and find the battery setting you changed is back to how it was. You did not touch it.&lt;/p&gt;

&lt;p&gt;That is not your memory playing tricks. It is a known OnePlus behaviour, and it is the reason this guide is different from the others in our series. On a OnePlus phone, fixing the settings once is not enough. You also need a way to &lt;strong&gt;keep&lt;/strong&gt; them fixed.&lt;/p&gt;

&lt;p&gt;This guide shows the settings that stop a screen-off camera on a OnePlus phone, the one that turns off the network at night, how to stop the battery setting from flipping back, and how to test the phone. It is written for a simple setup: one spare Android phone, no cloud account, no subscription, often no SIM card and only home or shop Wi-Fi.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why does my OnePlus phone stop the camera app when the screen is off?
&lt;/h2&gt;

&lt;p&gt;Because a camera with the screen off is exactly the kind of app that battery features are built to stop: it runs for hours while nobody looks at the phone.&lt;/p&gt;

&lt;p&gt;The volunteer site Don't Kill My App tracks how phone brands treat background apps and gives each brand a problem score out of 5. At the time of writing, &lt;strong&gt;OnePlus scores 5&lt;/strong&gt;, the worst score on the list, together with Xiaomi, Samsung and Huawei. Plain Android (AOSP) scores 0.&lt;/p&gt;

&lt;p&gt;The page explains why. It says OnePlus phones are known for a near-stock look, but:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"This may be true on the UX front but the exact opposite is valid for background process limits."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And about the OnePlus 5 and 6 generation:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"OnePlus introduced one of the most severe background limits on the market to date, dwarfing even those performed by Xiaomi or Huawei."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Under its section for app developers, the page says: "No known solution on the developer end."&lt;/p&gt;

&lt;p&gt;That line matters. An app can ask Android to keep running with the screen off. That is what a &lt;strong&gt;foreground service&lt;/strong&gt; is, and it is why a screen-off camera app shows a notification while it records. But the OnePlus switches below are not something an app can change for you. Only the person holding the phone can.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why do my OnePlus battery settings keep changing back?
&lt;/h2&gt;

&lt;p&gt;This is the OnePlus problem that other brands do not have in the same way.&lt;/p&gt;

&lt;p&gt;Don't Kill My App gives two reasons the fix does not stay fixed:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Updates reset it.&lt;/strong&gt; The page says the extra settings "even got reset with firmware updates", so "apps break again and users are required to re-enable those settings on a regular basis".&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The phone flips it by itself.&lt;/strong&gt; About the Battery optimization setting, the page warns: "Recently, OnePlus phones started reverting this setting randomly for random apps. So if you set it to be &lt;em&gt;not optimized&lt;/em&gt;, the next day it may be back to &lt;em&gt;optimized&lt;/em&gt;." It links a bug report on the OnePlus forum with the same complaint.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The page's answer is to do two things together: set the app to not optimized, &lt;strong&gt;and&lt;/strong&gt; lock it in the Recent apps screen. It says locking "may prevent the app from being killed in the background and the &lt;em&gt;Battery optimisation&lt;/em&gt; setting from being reverted", but also: "This is however, not 100%. You may have to check system settings every once in a while."&lt;/p&gt;

&lt;p&gt;So the plan for a OnePlus camera phone is: fix the settings, lock the app, and then &lt;strong&gt;check again on a schedule&lt;/strong&gt;. The weekly check is at the end of this guide.&lt;/p&gt;

&lt;h2&gt;
  
  
  The six settings that stop a screen-off camera on OnePlus
&lt;/h2&gt;

&lt;p&gt;Menu names change between OnePlus models and software versions. If a step does not match your phone, use the &lt;strong&gt;search box at the top of Settings&lt;/strong&gt; and type the bold words. You may not have every one of these. Do the ones you find, in this order.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Lock the camera app in Recent apps
&lt;/h3&gt;

&lt;p&gt;Do this first, because it is what helps the next setting stay put.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open the camera app.&lt;/li&gt;
&lt;li&gt;Open &lt;strong&gt;Recent apps&lt;/strong&gt;: swipe up from the bottom and hold.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Long-press&lt;/strong&gt; the camera app's window and tap &lt;strong&gt;Lock&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Check that the window now shows a &lt;strong&gt;closed padlock&lt;/strong&gt; icon.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Leave it locked. Do not use "clear all" on this phone. A locked app is skipped when you clear the list.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Battery optimization: Don't optimize
&lt;/h3&gt;

&lt;p&gt;Don't Kill My App gives two paths. Use whichever your phone has:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Settings → Apps → (gear icon) → Special access → Battery optimization&lt;/strong&gt;, or&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Settings → Battery → Battery optimization&lt;/strong&gt;, then switch the list to &lt;strong&gt;All apps&lt;/strong&gt; (menu at the top right).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Find your camera app and choose &lt;strong&gt;Don't optimize&lt;/strong&gt; (it may say &lt;strong&gt;Not optimized&lt;/strong&gt; afterwards).&lt;/p&gt;

&lt;p&gt;Then write down today's date. You will check this exact screen again in the weekly check, because this is the setting the page says can flip back.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Deep optimization or Adaptive Battery: off
&lt;/h3&gt;

&lt;p&gt;On the &lt;strong&gt;OnePlus 6 and later&lt;/strong&gt;, the page points to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Settings → Battery → Battery optimization → (three dots) → Advanced optimization&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are two options there, and the page says &lt;strong&gt;both are on by default&lt;/strong&gt;. The first is &lt;strong&gt;Deep optimization&lt;/strong&gt; (on some versions it is called &lt;strong&gt;Adaptive Battery&lt;/strong&gt;). The page is blunt about it:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"This is the main app killer. If you need any apps to run in the background, disable it."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Turn it &lt;strong&gt;off&lt;/strong&gt;. On a phone that lives on a charger and does only one job, there is little to lose.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Sleep standby optimization: off (this one cuts the network)
&lt;/h3&gt;

&lt;p&gt;The second option on the same screen is &lt;strong&gt;Sleep standby optimization&lt;/strong&gt;. This is the one that matters most if you watch the camera remotely. The page describes it like this:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"OnePlus tries to learn when you are usually asleep, and in those times it will then disable the phone's network connections."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Think about what that means for a camera phone. The hours the phone "learns" as your sleep are usually the hours you most want the camera working. If the phone turns its network off in that window, then a &lt;strong&gt;live view over Wi-Fi&lt;/strong&gt; and a &lt;strong&gt;YouTube Live stream&lt;/strong&gt; both need the network, so both can drop, even if nothing else looks wrong when you check the phone in the morning.&lt;/p&gt;

&lt;p&gt;Turn it &lt;strong&gt;off&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If your camera only fails at night, and works when you test it in the afternoon, check this setting first.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Enhanced optimization (older OnePlus phones)
&lt;/h3&gt;

&lt;p&gt;On phones &lt;strong&gt;older than the OnePlus 6&lt;/strong&gt;, the same menu has one option instead of two:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Settings → Battery → Battery optimization → (three dots) → Enhanced optimization&lt;/strong&gt; → &lt;strong&gt;off&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The page also notes that some users said the OnePlus 3 and earlier needed Doze turned off in Developer options. That is a whole-phone change. Only try it on an old phone that does nothing but camera duty, and only if the test below still fails.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. App Auto-Launch: allow the camera app
&lt;/h3&gt;

&lt;p&gt;The page says App Auto-Launch, on some OnePlus phones, "essentially prevents apps from working in the background". Search Settings for &lt;strong&gt;Auto-Launch&lt;/strong&gt; (or &lt;strong&gt;Auto launch&lt;/strong&gt;) and allow your camera app. If search finds nothing, your phone does not have this screen. Move on.&lt;/p&gt;

&lt;h3&gt;
  
  
  Also check: what swiping an app away does
&lt;/h3&gt;

&lt;p&gt;On most Android phones, swiping an app away in Recent apps does not stop a running foreground service. The page says OnePlus may be different: its "recent app clear behaviour" can be set so that "swiping the app to close will kill it". With the app locked (step 1) this matters less. But do not swipe the camera app away, and tell anyone else who uses the phone not to.&lt;/p&gt;

&lt;p&gt;And check &lt;strong&gt;Settings → Battery → Battery Saver&lt;/strong&gt; is off, and not set to turn on by itself. A camera phone on a charger does not need it. If the battery still drops while plugged in, the charger or cable is the problem, not the settings. We explained that in &lt;a href="https://dev.to/superfunicular/why-does-my-phone-security-cameras-battery-drop-even-though-it-is-plugged-in-weak-chargers-thin-19db"&gt;Why Does My Phone Security Camera's Battery Drop Even Though It Is Plugged In?&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Does this work without internet?
&lt;/h2&gt;

&lt;p&gt;Yes. None of the settings above need internet, a SIM card, or an account. They are local switches on the phone.&lt;/p&gt;

&lt;p&gt;That matters for a common setup in shops and homes: the camera phone has no SIM and only joins the local Wi-Fi. Recording to the phone's own storage does not need internet. A live view inside the same Wi-Fi network does not need internet either, but it &lt;strong&gt;does&lt;/strong&gt; need the phone's Wi-Fi to stay connected, which is why step 4 matters even on a network with no internet at all. Streaming to YouTube Live needs a working internet connection.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why an old OnePlus can still stop
&lt;/h2&gt;

&lt;p&gt;Even with every setting right, two different things can stop a camera:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Battery rules&lt;/strong&gt; (this guide). These are settings. You can change them, and on OnePlus you have to keep checking them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Android's low-memory killer.&lt;/strong&gt; When memory is full, Android itself closes apps, starting with the least important. A foreground service ranks high, but it is not untouchable.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The settings here fix the first one. For the second: use the phone for the camera only, remove apps you do not need, and do not run games or social apps next to the camera. We explained how Android picks what to stop in &lt;a href="https://dev.to/superfunicular/a-foreground-service-is-not-immortal-what-androids-low-memory-killer-does-to-a-247-camera-on-a-2-1470"&gt;A Foreground Service Is Not Immortal: What Android's Low Memory Killer Does to a 24/7 Camera on a 2 GB Phone&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The test: 10 minutes, then overnight
&lt;/h2&gt;

&lt;p&gt;Changing settings is not proof. Test the real phone with the real app.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Make the changes above. &lt;strong&gt;Restart the phone&lt;/strong&gt; once, then check the padlock is still on the camera app in Recent apps.&lt;/li&gt;
&lt;li&gt;Open the camera app, &lt;strong&gt;start recording&lt;/strong&gt;, and turn the screen off.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Note the time.&lt;/strong&gt; Put the phone on the charger. Do not touch it.&lt;/li&gt;
&lt;li&gt;Wait at least 10 minutes. If your app has a live view over Wi-Fi, &lt;strong&gt;open it from a second phone or laptop&lt;/strong&gt;. Is the picture still moving?&lt;/li&gt;
&lt;li&gt;Then do it again &lt;strong&gt;overnight&lt;/strong&gt;, and check the live view once late at night if you can. Sleep standby is built around your sleeping hours, so an afternoon test can pass while the night fails.&lt;/li&gt;
&lt;li&gt;In the morning, unlock the camera phone and look at the recordings. Do the files continue past the time you noted, with no long gap?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;How to read a failure:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A gap within minutes of the screen going off usually means step 2 or step 3 was missed.&lt;/li&gt;
&lt;li&gt;Recordings are fine, but the &lt;strong&gt;live view was dead at night&lt;/strong&gt;: look at step 4 (Sleep standby).&lt;/li&gt;
&lt;li&gt;Everything worked last week and fails now: the setting flipped back. Do the weekly check.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The weekly OnePlus check (two minutes)
&lt;/h2&gt;

&lt;p&gt;This is the part other brands do not need as often. Once a week, and after &lt;strong&gt;every system update&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;[ ] Recent apps: camera app still shows the &lt;strong&gt;padlock&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;[ ] Battery optimization: camera app still &lt;strong&gt;Don't optimize&lt;/strong&gt; / Not optimized&lt;/li&gt;
&lt;li&gt;[ ] Advanced optimization: &lt;strong&gt;Deep optimization&lt;/strong&gt; (or Adaptive Battery) still &lt;strong&gt;off&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;[ ] Advanced optimization: &lt;strong&gt;Sleep standby optimization&lt;/strong&gt; still &lt;strong&gt;off&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;[ ] Battery Saver still &lt;strong&gt;off&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;[ ] Open the live view once from another device&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If one of them has changed, set it again and run the 10-minute test. If the battery optimization setting keeps flipping even with the app locked, that is the behaviour the OnePlus bug report describes. Keep the weekly check going. It is the only fix the page offers.&lt;/p&gt;

&lt;h2&gt;
  
  
  If you have a different brand
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;OPPO, realme or vivo:&lt;/strong&gt; see &lt;a href="https://dev.to/superfunicular/why-does-my-oppo-realme-or-vivo-phone-stop-the-camera-app-with-the-screen-off-auto-launch-2k21"&gt;Why Does My OPPO, realme or vivo Phone Stop the Camera App With the Screen Off?&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Motorola:&lt;/strong&gt; see &lt;a href="https://dev.to/superfunicular/why-does-my-motorola-phone-stop-the-camera-app-with-the-screen-off-unrestricted-battery-usage-2apn"&gt;Why Does My Motorola Phone Stop the Camera App With the Screen Off?&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Huawei or Honor:&lt;/strong&gt; see &lt;a href="https://dev.to/superfunicular/why-does-my-huawei-or-honor-phone-stop-the-camera-app-with-the-screen-off-app-launch-protected-p3f"&gt;Why Does My Huawei or Honor Phone Stop the Camera App With the Screen Off?&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Redmi, POCO or Xiaomi:&lt;/strong&gt; see &lt;a href="https://dev.to/superfunicular/why-does-my-redmi-poco-or-xiaomi-phone-stop-the-camera-app-with-the-screen-off-autostart-battery-29kg"&gt;Why Does My Redmi, POCO or Xiaomi Phone Stop the Camera App With the Screen Off?&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tecno, Infinix or itel:&lt;/strong&gt; see &lt;a href="https://dev.to/superfunicular/why-does-my-tecno-infinix-or-itel-phone-stop-the-camera-app-with-the-screen-off-phone-master-fa4"&gt;Why Does My Tecno, Infinix or itel Phone Stop the Camera App With the Screen Off?&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Developers&lt;/strong&gt; who want the Android side (Doze, foreground services, and why vendor layers sit on top) can read &lt;a href="https://dev.to/superfunicular/why-does-my-android-camera-stop-recording-when-the-screen-turns-off-doze-workmanager-and-the-1a5d"&gt;Why Does My Android Camera Stop Recording When the Screen Turns Off?&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;New to this? Start with &lt;a href="https://dev.to/superfunicular/turn-an-old-android-phone-into-a-screen-off-security-camera-no-cloud-lan-only-5cll"&gt;Turn an old Android phone into a screen-off security camera (no cloud, LAN-only)&lt;/a&gt;, then come back to this checklist before you leave the phone alone.&lt;/p&gt;

&lt;h3&gt;
  
  
  Sources
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Don't Kill My App — &lt;a href="https://dontkillmyapp.com/oneplus" rel="noopener noreferrer"&gt;OnePlus&lt;/a&gt; (page dated 9 June 2026; score, quotes, App locking, Battery optimization paths and the reverting warning, App Auto-Launch, Advanced optimization with Deep optimization / Adaptive Battery and Sleep standby optimization, Enhanced optimization, recent app clearing behaviour, Doze note for 1+3 and earlier). Scores read from the site's vendor list on 18 November 2026.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Don't Kill My App is a volunteer project, not official OnePlus documentation. Menus differ by model and software version. That is exactly why the test, and the weekly check, matter more than the menu.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Background Camera RemoteStream&lt;/strong&gt; turns an Android phone into a screen-off camera: it records with the screen off and keeps recordings on the phone, with no cloud account needed. Its Pro tier adds a live browser view over your own Wi-Fi and YouTube Live streaming; check the Play listing for what is free and what is Pro.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Google Play: &lt;a href="https://play.google.com/store/apps/details?id=com.superfunicular.digicam" rel="noopener noreferrer"&gt;https://play.google.com/store/apps/details?id=com.superfunicular.digicam&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Website: &lt;a href="https://superfunicular.com" rel="noopener noreferrer"&gt;https://superfunicular.com&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>android</category>
      <category>tutorial</category>
      <category>privacy</category>
      <category>security</category>
    </item>
    <item>
      <title>ln -sf Left My latest Link on Day One and Exited 0: Updating a Symlink to the Newest Camera Clip Folder</title>
      <dc:creator>Super Funicular</dc:creator>
      <pubDate>Tue, 17 Nov 2026 21:55:48 +0000</pubDate>
      <link>https://dev.to/superfunicular/ln-sf-left-my-latest-link-on-day-one-and-exited-0-updating-a-symlink-to-the-newest-camera-clip-43m2</link>
      <guid>https://dev.to/superfunicular/ln-sf-left-my-latest-link-on-day-one-and-exited-0-updating-a-symlink-to-the-newest-camera-clip-43m2</guid>
      <description>&lt;p&gt;A folder of camera clips sorted into one subfolder per day usually grows a convenience link called &lt;code&gt;latest&lt;/code&gt;, so a viewer, a backup job or a person at a terminal can open the newest clips without working out the date. The script that keeps it current is one line, run once a day with that day's date filled in:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ln -sf 2026-11-14 latest&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;I tested that line over three days of folders. On the second day it exited 0 and left &lt;code&gt;latest&lt;/code&gt; pointing at day one. On the third day it did the same. Each run created a new link, just not the one it was asked to replace: it put it inside day one's folder, where it points at itself.&lt;/p&gt;

&lt;p&gt;Two more things turned up around the same link. A target written from the wrong directory gives a link that points nowhere, and &lt;code&gt;ln&lt;/code&gt; does not object. And the backup copy most people would write, &lt;code&gt;cp -r&lt;/code&gt; of the link, copied the link and not one clip.&lt;/p&gt;

&lt;p&gt;Disclosure: I make an Android camera app. Nothing below uses its code or describes how it stores anything. The folders are empty or hold a few bytes of random data, and every output is pasted from the scripts shown. Versions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ln (GNU coreutils) 8.32
cp (GNU coreutils) 8.32
strace -- version 5.16
Linux 6.8.0-138-generic
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Three days with ln -sf
&lt;/h2&gt;

&lt;p&gt;Day one creates the link. Days two and three run the usual update line.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/sh&lt;/span&gt;
&lt;span class="c"&gt;# Two days of clip folders and a "latest" link, updated the way most scripts do it.&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; -e
rm -rf clips &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; mkdir -p clips/2026-11-13 clips/2026-11-14 clips/2026-11-15
&lt;span class="nb"&gt;cd&lt;/span&gt; clips
ln -s 2026-11-13 latest              &lt;span class="c"&gt;# day one: no link yet, works&lt;/span&gt;
ln -sf 2026-11-14 latest&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"day two exit=$?"&lt;/span&gt;
ln -sf 2026-11-15 latest&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"day three exit=$?"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"latest -&amp;gt; $(readlink latest)"&lt;/span&gt;
find . -type l -printf &lt;span class="s1"&gt;'%p -&amp;gt; %l\n'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; sort
&lt;span class="k"&gt;for&lt;/span&gt; l &lt;span class="k"&gt;in&lt;/span&gt; 2026-11-13/*&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="nb"&gt;test&lt;/span&gt; -e &lt;span class="s2"&gt;"$l"&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"$l does not resolve: $(ls "&lt;/span&gt;&lt;span class="nv"&gt;$l&lt;/span&gt;/&lt;span class="s2"&gt;" 2&amp;gt;&amp;amp;1 | sed 's/^ls: //')"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;day two exit=0
day three exit=0
latest -&amp;gt; 2026-11-13
./2026-11-13/2026-11-14 -&amp;gt; 2026-11-14
./2026-11-13/2026-11-15 -&amp;gt; 2026-11-15
./latest -&amp;gt; 2026-11-13
2026-11-13/2026-11-14 does not resolve: cannot access '2026-11-13/2026-11-14/': Too many levels of symbolic links
2026-11-13/2026-11-15 does not resolve: cannot access '2026-11-13/2026-11-15/': Too many levels of symbolic links
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both updates exited 0. &lt;code&gt;latest&lt;/code&gt; still names &lt;code&gt;2026-11-13&lt;/code&gt;, and the folder for that day now holds two links nobody asked for.&lt;/p&gt;

&lt;p&gt;The GNU manual describes why. When the last argument is a symbolic link to a directory, &lt;code&gt;ln&lt;/code&gt; has a choice between replacing the link and creating a new link inside the directory it points to. The manual is plain about which one it picks:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"The default is to treat a destination that is a symlink to a directory just like a directory."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So &lt;code&gt;ln -sf 2026-11-14 latest&lt;/code&gt; read &lt;code&gt;latest&lt;/code&gt; as the folder &lt;code&gt;2026-11-13&lt;/code&gt; and made &lt;code&gt;2026-11-13/2026-11-14&lt;/code&gt;. The &lt;code&gt;-f&lt;/code&gt; did nothing useful, because there was nothing at that name to replace.&lt;/p&gt;

&lt;p&gt;The stray links are broken in an odd way. Each holds the relative string &lt;code&gt;2026-11-14&lt;/code&gt;, and the manual says "A relative symbolic link is resolved in relation to the directory that contains the link". The link lives in &lt;code&gt;2026-11-13/&lt;/code&gt;, so &lt;code&gt;2026-11-14&lt;/code&gt; resolves to &lt;code&gt;2026-11-13/2026-11-14&lt;/code&gt;, which is the link itself. That is why &lt;code&gt;ls&lt;/code&gt; reported a loop rather than a missing file.&lt;/p&gt;

&lt;p&gt;Nothing in the output of the update line hints at any of this. A script that checks the exit status sees success every day, and a viewer that opens &lt;code&gt;latest&lt;/code&gt; keeps showing the first day's clips.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two flags that replace the link
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;ln&lt;/code&gt; has two options for this: &lt;code&gt;-n&lt;/code&gt; (&lt;code&gt;--no-dereference&lt;/code&gt;) and &lt;code&gt;-T&lt;/code&gt; (&lt;code&gt;--no-target-directory&lt;/code&gt;). The same three days, once with each:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/sh&lt;/span&gt;
&lt;span class="c"&gt;# The same three days with -n, and with -T.&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; -e
&lt;span class="k"&gt;for&lt;/span&gt; opt &lt;span class="k"&gt;in&lt;/span&gt; -sfn -sfT&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  rm -rf clips &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; mkdir -p clips/2026-11-13 clips/2026-11-14 clips/2026-11-15
  &lt;span class="nb"&gt;cd&lt;/span&gt; clips
  ln -s 2026-11-13 latest
  ln &lt;span class="nv"&gt;$opt&lt;/span&gt; 2026-11-14 latest
  ln &lt;span class="nv"&gt;$opt&lt;/span&gt; 2026-11-15 latest
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"$opt: latest -&amp;gt; $(readlink latest); links: $(find . -type l | wc -l)"&lt;/span&gt;
  &lt;span class="nb"&gt;cd&lt;/span&gt; ..
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-sfn: latest -&amp;gt; 2026-11-15; links: 1
-sfT: latest -&amp;gt; 2026-11-15; links: 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both left one link, pointing at the last day. The difference is in how far each goes. &lt;code&gt;-n&lt;/code&gt; only stops &lt;code&gt;ln&lt;/code&gt; from following a final argument that is a symlink to a directory. &lt;code&gt;-T&lt;/code&gt; stops it from treating the final argument as a directory at all, symlink or not. The manual on &lt;code&gt;-n&lt;/code&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"This option is weaker than the --no-target-directory (-T) option, so it has no effect if both options are given."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The case where the difference shows is a real directory sitting where the link should be, for example if someone once ran &lt;code&gt;mkdir latest&lt;/code&gt; by hand. &lt;code&gt;-n&lt;/code&gt; would then put the new link inside that directory, the same quiet failure as before. &lt;code&gt;-T&lt;/code&gt; refuses, because it will not replace a directory with a link. I would rather have the refusal, so I use &lt;code&gt;-sfT&lt;/code&gt; in scripts and &lt;code&gt;-sfn&lt;/code&gt; at a prompt, where I can see what happened.&lt;/p&gt;

&lt;h2&gt;
  
  
  The target is stored as typed
&lt;/h2&gt;

&lt;p&gt;The second trap shows up when the update runs from the parent folder instead of from inside &lt;code&gt;clips&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/sh&lt;/span&gt;
&lt;span class="c"&gt;# Making the link from one directory up: the target string is stored as typed.&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; -e
rm -rf clips &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; mkdir -p clips/2026-11-15
touch clips/2026-11-15/clip_0001.mp4
ln -sfn clips/2026-11-15 clips/latest
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"stored: $(readlink clips/latest)"&lt;/span&gt;
ls clips/latest/ 2&lt;span class="o"&gt;&amp;gt;&amp;amp;&lt;/span&gt;1 &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="nb"&gt;test&lt;/span&gt; -e clips/latest &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"resolves"&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"dangling"&lt;/span&gt;
ln -sfn 2026-11-15 clips/latest
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"stored: $(readlink clips/latest)"&lt;/span&gt;
ls clips/latest/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;stored: clips/2026-11-15
ls: cannot access 'clips/latest/': No such file or directory
dangling
stored: 2026-11-15
clip_0001.mp4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;ln&lt;/code&gt; stored the string &lt;code&gt;clips/2026-11-15&lt;/code&gt;, exactly as typed. Read from inside &lt;code&gt;clips/&lt;/code&gt;, where the link lives, that names &lt;code&gt;clips/clips/2026-11-15&lt;/code&gt;, which does not exist. The manual allows this without comment: "There are no restrictions against creating dangling symbolic links."&lt;/p&gt;

&lt;p&gt;The fix is to write the target as it should be read from the link's own folder, here just the date. GNU &lt;code&gt;ln&lt;/code&gt; also has &lt;code&gt;-r&lt;/code&gt; (&lt;code&gt;--relative&lt;/code&gt;), which works out that string for you from the current directory. I did not add &lt;code&gt;-r&lt;/code&gt; to the test above, so it is in the list of things I did not check.&lt;/p&gt;

&lt;h2&gt;
  
  
  Copying the latest folder to a backup drive
&lt;/h2&gt;

&lt;p&gt;The third trap is on the reading side. A one-off copy of the newest clips to another drive is often written against the link, because the link is the easy name to remember:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/sh&lt;/span&gt;
&lt;span class="c"&gt;# Copying the "latest" folder to a backup drive, four ways.&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; -e
rm -rf clips backup &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; mkdir -p clips/2026-11-15 backup
head -c 4096 /dev/urandom &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; clips/2026-11-15/clip_0001.mp4
ln -sfn 2026-11-15 clips/latest
&lt;span class="k"&gt;for&lt;/span&gt; cmd &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="s2"&gt;"cp -r clips/latest backup/r"&lt;/span&gt; &lt;span class="s2"&gt;"cp -r clips/latest/ backup/r_slash"&lt;/span&gt; \
           &lt;span class="s2"&gt;"cp -rL clips/latest backup/rL"&lt;/span&gt; &lt;span class="s2"&gt;"cp -a clips/latest backup/a"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="nv"&gt;$cmd&lt;/span&gt;
  &lt;span class="nv"&gt;dst&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;${cmd##* }&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; -L &lt;span class="s2"&gt;"$dst"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt; &lt;span class="nv"&gt;kind&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"symlink -&amp;gt; $(readlink "&lt;/span&gt;&lt;span class="nv"&gt;$dst&lt;/span&gt;&lt;span class="s2"&gt;")"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="nv"&gt;kind&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"directory"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;fi&lt;/span&gt;
  &lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s1"&gt;'%-36s %-26s %s\n'&lt;/span&gt; &lt;span class="s2"&gt;"$cmd"&lt;/span&gt; &lt;span class="s2"&gt;"$kind"&lt;/span&gt; &lt;span class="s2"&gt;"$(ls "&lt;/span&gt;&lt;span class="nv"&gt;$dst&lt;/span&gt;&lt;span class="s2"&gt;"/ 2&amp;gt;&amp;amp;1 | tr '\n' ' ')"&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cp -r clips/latest backup/r          symlink -&amp;gt; 2026-11-15      ls: cannot access 'backup/r/': No such file or directory 
cp -r clips/latest/ backup/r_slash   directory                  clip_0001.mp4 
cp -rL clips/latest backup/rL        directory                  clip_0001.mp4 
cp -a clips/latest backup/a          symlink -&amp;gt; 2026-11-15      ls: cannot access 'backup/a/': No such file or directory 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Plain &lt;code&gt;cp -r clips/latest&lt;/code&gt; and &lt;code&gt;cp -a clips/latest&lt;/code&gt; both copied the link, not the folder. The backup holds a link containing the string &lt;code&gt;2026-11-15&lt;/code&gt;, which on the backup drive points at nothing. Both commands exited 0, since copying a link is a successful copy.&lt;/p&gt;

&lt;p&gt;The manual says when &lt;code&gt;cp&lt;/code&gt; follows a link it was given:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"When copying from a symbolic link, cp normally follows the link only when not copying recursively or when --link (-l) is used."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Recursive copying is exactly the case where it does not. Two forms did copy the clip: a trailing slash on the source (&lt;code&gt;clips/latest/&lt;/code&gt;), which makes the path name the directory and not the link, and &lt;code&gt;-L&lt;/code&gt;, which follows every link it meets. &lt;code&gt;-H&lt;/code&gt; would follow only links named on the command line; I did not run it.&lt;/p&gt;

&lt;p&gt;The same question applies to anything else that walks the folder, such as &lt;code&gt;rsync&lt;/code&gt;, &lt;code&gt;tar&lt;/code&gt; or a sync client: each has its own rule about links, and a link named &lt;code&gt;latest&lt;/code&gt; at the top of the tree is the one most likely to be handed to them directly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Is the swap atomic?
&lt;/h2&gt;

&lt;p&gt;A viewer reading &lt;code&gt;latest&lt;/code&gt; at the moment the link is replaced could, in principle, catch the name missing. The manual for &lt;code&gt;ln&lt;/code&gt; says that does not happen with &lt;code&gt;-f&lt;/code&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Unless the --backup (-b) option is used there is no brief moment when the destination does not exist"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That line is from the current manual. My &lt;code&gt;ln&lt;/code&gt; is 8.32, so I traced the system calls it made:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/sh&lt;/span&gt;
&lt;span class="c"&gt;# Which system calls ln -sfn makes when it replaces the link.&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; -e
rm -rf clips &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; mkdir -p clips/2026-11-14 clips/2026-11-15
&lt;span class="nb"&gt;cd&lt;/span&gt; clips
ln -s 2026-11-14 latest
strace -f -e &lt;span class="nv"&gt;trace&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;symlink,symlinkat,unlink,unlinkat,rename,renameat,renameat2 \
  ln -sfn 2026-11-15 latest 2&lt;span class="o"&gt;&amp;gt;&amp;amp;&lt;/span&gt;1 &lt;span class="o"&gt;|&lt;/span&gt; grep -v &lt;span class="s1"&gt;'^+++'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; sed -E &lt;span class="s1"&gt;'s/"Cu[A-Za-z0-9]{6}"/"&amp;lt;random name&amp;gt;"/g'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;symlinkat("2026-11-15", AT_FDCWD, "latest") = -1 EEXIST (File exists)
symlinkat("2026-11-15", AT_FDCWD, "&amp;lt;random name&amp;gt;") = 0
renameat(AT_FDCWD, "&amp;lt;random name&amp;gt;", AT_FDCWD, "latest") = 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It first tried to create &lt;code&gt;latest&lt;/code&gt; directly, got &lt;code&gt;EEXIST&lt;/code&gt;, made the new link under a random name, then renamed it over &lt;code&gt;latest&lt;/code&gt;. A rename replaces the old name in one step, so a reader sees either the old link or the new one. That matches the manual for this build. Older or non-GNU versions of &lt;code&gt;ln&lt;/code&gt; may delete and re-create instead; if a reader depends on it, trace your own.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I would write instead
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Update the link with &lt;code&gt;ln -sfT&lt;/code&gt;&lt;/strong&gt;: &lt;code&gt;ln -sfT 2026-11-15 clips/latest&lt;/code&gt;. The target is the bare folder name even when the command runs from the parent folder, because it is read from where the link lives. If &lt;code&gt;latest&lt;/code&gt; was ever turned into a real directory, this fails loudly instead of nesting.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Write the target as seen from the link's folder.&lt;/strong&gt; For a link inside &lt;code&gt;clips/&lt;/code&gt;, the target is the bare folder name. If the script runs elsewhere, &lt;code&gt;cd&lt;/code&gt; into &lt;code&gt;clips&lt;/code&gt; first, or use &lt;code&gt;ln -r&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Check the result, not the exit status.&lt;/strong&gt; After the update, compare &lt;code&gt;readlink clips/latest&lt;/code&gt; with the date you meant. That catches every failure above, including the ones that exit 0.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Copy through the link with a trailing slash or &lt;code&gt;-L&lt;/code&gt;.&lt;/strong&gt; &lt;code&gt;cp -r clips/latest/ /mnt/backup/2026-11-15&lt;/code&gt; copies the clips. Naming the destination by date also keeps the backup readable when the link is gone.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Clean up after the old habit.&lt;/strong&gt; &lt;code&gt;find clips -mindepth 2 -type l&lt;/code&gt; lists links nested inside day folders; on the folders above, those are only the strays.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Things I did not test
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;BSD and macOS &lt;code&gt;ln&lt;/code&gt; and &lt;code&gt;cp&lt;/code&gt;.&lt;/strong&gt; BSD &lt;code&gt;ln&lt;/code&gt; has its own &lt;code&gt;-h&lt;/code&gt; and &lt;code&gt;-n&lt;/code&gt; flags, and its &lt;code&gt;cp&lt;/code&gt; follows different defaults. Everything here is GNU coreutils 8.32 on Linux.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;ln -r&lt;/code&gt; and &lt;code&gt;cp -H&lt;/code&gt;.&lt;/strong&gt; Both are described above from the manual only.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Readers.&lt;/strong&gt; I did not run a viewer or web server against &lt;code&gt;latest&lt;/code&gt; during the swap. The strace shows a rename; how a particular reader caches a resolved path is a separate question.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Other file systems.&lt;/strong&gt; The test ran on a local Linux file system. FAT and exFAT, common on SD cards and USB drives, do not store symbolic links at all, so a copy to one of them cannot keep the link either way.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Sources.&lt;/strong&gt; &lt;code&gt;ln&lt;/code&gt; quotes are from the GNU coreutils manual page &lt;a href="https://www.gnu.org/software/coreutils/ln" rel="noopener noreferrer"&gt;ln: Make links between files&lt;/a&gt;. The &lt;code&gt;cp&lt;/code&gt; quote is from &lt;a href="https://www.gnu.org/software/coreutils/manual/html_node/cp-invocation.html" rel="noopener noreferrer"&gt;cp: Copy files and directories&lt;/a&gt;. Outputs are pasted unedited from the scripts above.&lt;/p&gt;

&lt;p&gt;If you want an old Android phone recording in the background so there is a folder of daily clips to point a link at, the app I make is &lt;a href="https://play.google.com/store/apps/details?id=com.superfunicular.digicam" rel="noopener noreferrer"&gt;Background Camera RemoteStream on Google Play&lt;/a&gt;. Nothing above depends on it.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ln -sf&lt;/code&gt; exits 0 while nesting its new link under the old day's folder, so replace &lt;code&gt;latest&lt;/code&gt; using &lt;code&gt;-sfT&lt;/code&gt;, store its target relative to where it lives, and back it up through &lt;code&gt;latest/&lt;/code&gt;.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>bash</category>
      <category>devops</category>
      <category>android</category>
    </item>
    <item>
      <title>I Rotated a Running Script's Log and Every Line Kept Going to the Old File: mv, copytruncate and &gt; vs &gt;&gt;, Measured</title>
      <dc:creator>Super Funicular</dc:creator>
      <pubDate>Tue, 17 Nov 2026 13:56:47 +0000</pubDate>
      <link>https://dev.to/superfunicular/i-rotated-a-running-scripts-log-and-every-line-kept-going-to-the-old-file-mv-copytruncate-and--28n0</link>
      <guid>https://dev.to/superfunicular/i-rotated-a-running-scripts-log-and-every-line-kept-going-to-the-old-file-mv-copytruncate-and--28n0</guid>
      <description>&lt;p&gt;A script that records or encodes camera clips all night usually logs as it goes, often with nothing fancier than &lt;code&gt;&amp;gt;&amp;gt; rec.log&lt;/code&gt; on the loop. Sooner or later that log gets big enough that someone rotates it while the script is still running, by hand with &lt;code&gt;mv&lt;/code&gt; or with a &lt;code&gt;logrotate&lt;/code&gt; rule. Whether the next line lands in the new log, the old one, or nowhere depends on how the writer opened the file, not on how carefully the rotation was done.&lt;/p&gt;

&lt;p&gt;I ran one stand-in writer three ways and rotated it four ways. Renaming the log, even with a fresh empty file put in its place, sent every later line into the renamed file. Copy-then-truncate kept every line in my fast runs and lost 17 of them once the copy was slowed a little. Copy-then-truncate under a writer opened with &lt;code&gt;&amp;gt;&lt;/code&gt; instead of &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; produced a log whose first 2580 bytes were zeros.&lt;/p&gt;

&lt;p&gt;Disclosure: I make an Android camera app. Nothing below uses its code or describes how it works. The writer is a shell loop that prints numbered lines, and every output is pasted from the script shown. Versions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GNU bash, version 5.1.16(1)-release (aarch64-unknown-linux-gnu)
cp (GNU coreutils) 8.32
Linux 6.8.0-138-generic
ext2/ext3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The writer, the rotations, and the count
&lt;/h2&gt;

&lt;p&gt;The writer prints 600 numbered lines, one every 10 ms, so a run takes about six seconds. About three seconds in, the script rotates the log, then waits for the writer to finish and counts what ended up in &lt;code&gt;rec.log.1&lt;/code&gt; (the rotated file) and &lt;code&gt;rec.log&lt;/code&gt; (the name the writer was told to use). Every line is numbered, so the last check can say exactly how many reached neither file.&lt;/p&gt;

&lt;p&gt;The three writers differ only in where the redirect sits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;append:&lt;/strong&gt; the whole loop is redirected once with &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt;, so the file is opened once and held for the whole run. This is the common way to log a loop.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;trunc:&lt;/strong&gt; the same, but with &lt;code&gt;&amp;gt;&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;perline:&lt;/strong&gt; the &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; is on the &lt;code&gt;printf&lt;/code&gt; inside the loop, so the file is opened, written and closed again for every line.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The four rotations:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;mv:&lt;/strong&gt; rename the log and do nothing else.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;mv+create:&lt;/strong&gt; rename it and create a new empty file under the old name, which is what the &lt;code&gt;create&lt;/code&gt; directive in &lt;code&gt;logrotate&lt;/code&gt; does.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;copytruncate:&lt;/strong&gt; copy the log to the rotated name, then truncate the original to zero, which is what the &lt;code&gt;copytruncate&lt;/code&gt; directive does.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;copytruncate-slow:&lt;/strong&gt; the same with a 0.2 second pause between the copy and the truncate, standing in for a copy that takes a moment because the log is large or the disk is busy.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;
&lt;span class="c"&gt;# Rotate a log while the script writing it is still running, six ways.&lt;/span&gt;
&lt;span class="c"&gt;# The writer prints 600 numbered lines, one every 10 ms. Rotation happens&lt;/span&gt;
&lt;span class="c"&gt;# about 3 seconds in. Afterwards, count what ended up where.&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; -u
writer&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;  &lt;span class="c"&gt;# $1: append | trunc | perline&lt;/span&gt;
  &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nv"&gt;$1&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt;
    append&lt;span class="o"&gt;)&lt;/span&gt;  &lt;span class="o"&gt;(&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; i &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;$(&lt;/span&gt;seq 1 600&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s1"&gt;'line %04d\n'&lt;/span&gt; &lt;span class="s2"&gt;"$i"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; sleep 0.01&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;done&lt;/span&gt; &lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; rec.log &lt;span class="o"&gt;;&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    trunc&lt;span class="o"&gt;)&lt;/span&gt;   &lt;span class="o"&gt;(&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; i &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;$(&lt;/span&gt;seq 1 600&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s1"&gt;'line %04d\n'&lt;/span&gt; &lt;span class="s2"&gt;"$i"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; sleep 0.01&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;done&lt;/span&gt; &lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;  rec.log &lt;span class="o"&gt;;&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    perline&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; i &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;$(&lt;/span&gt;seq 1 600&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s1"&gt;'line %04d\n'&lt;/span&gt; &lt;span class="s2"&gt;"$i"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; rec.log&lt;span class="o"&gt;;&lt;/span&gt; sleep 0.01&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;done&lt;/span&gt; &lt;span class="o"&gt;;&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;esac&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
rotate&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;  &lt;span class="c"&gt;# $1: mv | mv+create | copytruncate | copytruncate-slow&lt;/span&gt;
  &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nv"&gt;$1&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt;
    mv&lt;span class="o"&gt;)&lt;/span&gt;                mv rec.log rec.log.1 &lt;span class="o"&gt;;&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    mv+create&lt;span class="o"&gt;)&lt;/span&gt;         mv rec.log rec.log.1&lt;span class="o"&gt;;&lt;/span&gt; : &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; rec.log &lt;span class="o"&gt;;&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    copytruncate&lt;span class="o"&gt;)&lt;/span&gt;      cp rec.log rec.log.1&lt;span class="o"&gt;;&lt;/span&gt; : &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; rec.log &lt;span class="o"&gt;;&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    copytruncate-slow&lt;span class="o"&gt;)&lt;/span&gt; cp rec.log rec.log.1&lt;span class="o"&gt;;&lt;/span&gt; sleep 0.2&lt;span class="o"&gt;;&lt;/span&gt; : &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; rec.log &lt;span class="o"&gt;;&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;esac&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
report&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;local&lt;/span&gt; f n nul
  &lt;span class="k"&gt;for&lt;/span&gt; f &lt;span class="k"&gt;in&lt;/span&gt; rec.log.1 rec.log&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; -e &lt;span class="s2"&gt;"$f"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
      &lt;span class="nv"&gt;n&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;grep -ac &lt;span class="s1"&gt;'^line'&lt;/span&gt; &lt;span class="s2"&gt;"$f"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nv"&gt;nul&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;tr -dc &lt;span class="s1"&gt;'\0'&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="s2"&gt;"$f"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; wc -c&lt;span class="o"&gt;)&lt;/span&gt;
      &lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s1"&gt;'  %-9s %6d bytes  %3d lines  %5d NUL bytes\n'&lt;/span&gt; &lt;span class="s2"&gt;"$f"&lt;/span&gt; &lt;span class="s2"&gt;"$(stat -c %s "&lt;/span&gt;&lt;span class="nv"&gt;$f&lt;/span&gt;&lt;span class="s2"&gt;")"&lt;/span&gt; &lt;span class="s2"&gt;"$n"&lt;/span&gt; &lt;span class="s2"&gt;"$nul"&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;
      &lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s1"&gt;'  %-9s (does not exist)\n'&lt;/span&gt; &lt;span class="s2"&gt;"$f"&lt;/span&gt;
    &lt;span class="k"&gt;fi&lt;/span&gt;
  &lt;span class="k"&gt;done&lt;/span&gt;
  &lt;span class="nv"&gt;missing&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;comm -23 &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;seq -f &lt;span class="s1"&gt;'line %04g'&lt;/span&gt; 1 600&lt;span class="o"&gt;)&lt;/span&gt; \
                     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;cat rec.log.1 rec.log 2&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;/dev/null &lt;span class="o"&gt;|&lt;/span&gt; tr -d &lt;span class="s1"&gt;'\0'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; sort -u&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; wc -l&lt;span class="o"&gt;)&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"  lines missing from both files: $missing"&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
run&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;  &lt;span class="c"&gt;# $1 writer style, $2 rotation&lt;/span&gt;
  &lt;span class="kd"&gt;local&lt;/span&gt; d&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nv"&gt;d&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;mktemp -d&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;cd&lt;/span&gt; &lt;span class="s2"&gt;"$d"&lt;/span&gt;
  writer &lt;span class="s2"&gt;"$1"&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="kd"&gt;local&lt;/span&gt; &lt;span class="nv"&gt;w&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$!&lt;/span&gt;
  sleep 3&lt;span class="o"&gt;;&lt;/span&gt; rotate &lt;span class="s2"&gt;"$2"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;wait&lt;/span&gt; &lt;span class="s2"&gt;"$w"&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"writer=$1 rotation=$2"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; report&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt;
  &lt;span class="nb"&gt;cd&lt;/span&gt; /&lt;span class="o"&gt;;&lt;/span&gt; rm -rf &lt;span class="s2"&gt;"$d"&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
run append  mv
run append  mv+create
run perline mv+create
run append  copytruncate
run append  copytruncate-slow
run trunc   copytruncate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;writer=append rotation=mv
  rec.log.1   6000 bytes  600 lines      0 NUL bytes
  rec.log   (does not exist)
  lines missing from both files: 0

writer=append rotation=mv+create
  rec.log.1   6000 bytes  600 lines      0 NUL bytes
  rec.log        0 bytes    0 lines      0 NUL bytes
  lines missing from both files: 0

writer=perline rotation=mv+create
  rec.log.1   2510 bytes  251 lines      0 NUL bytes
  rec.log     3490 bytes  349 lines      0 NUL bytes
  lines missing from both files: 0

writer=append rotation=copytruncate
  rec.log.1   2520 bytes  252 lines      0 NUL bytes
  rec.log     3480 bytes  348 lines      0 NUL bytes
  lines missing from both files: 0

writer=append rotation=copytruncate-slow
  rec.log.1   2600 bytes  260 lines      0 NUL bytes
  rec.log     3230 bytes  323 lines      0 NUL bytes
  lines missing from both files: 17

writer=trunc rotation=copytruncate
  rec.log.1   2580 bytes  258 lines      0 NUL bytes
  rec.log     6000 bytes  341 lines   2580 NUL bytes
  lines missing from both files: 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Renaming: the writer follows the file, not the name
&lt;/h2&gt;

&lt;p&gt;With &lt;code&gt;mv&lt;/code&gt; alone, all 600 lines are in &lt;code&gt;rec.log.1&lt;/code&gt; and &lt;code&gt;rec.log&lt;/code&gt; does not exist. With &lt;code&gt;mv+create&lt;/code&gt;, all 600 are still in &lt;code&gt;rec.log.1&lt;/code&gt;, and the new &lt;code&gt;rec.log&lt;/code&gt; sits at 0 bytes for the rest of the run.&lt;/p&gt;

&lt;p&gt;That is how renaming works on Linux. The writer opened the file once, when the loop started, and from then on it writes to that open file, whatever it is called. Renaming changes the name in the directory, not the file the writer holds. Creating a new file under the old name makes a second, unrelated file that nothing is writing to. The &lt;code&gt;logrotate&lt;/code&gt; manual expects this: its &lt;code&gt;delaycompress&lt;/code&gt; directive exists because a program "might continue writing to the previous log file for some time."&lt;/p&gt;

&lt;p&gt;The usual fix is to tell the program to reopen its log after the rename, which is what the &lt;code&gt;postrotate&lt;/code&gt; scripts in the &lt;code&gt;logrotate&lt;/code&gt; examples do by sending a signal. A plain shell loop has no handler for that, so for a shell writer the useful fix is in the next row.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reopening on every line
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;perline&lt;/strong&gt; writer survived the same &lt;code&gt;mv+create&lt;/code&gt; rotation: 251 lines before the rename went into &lt;code&gt;rec.log.1&lt;/code&gt;, the other 349 went into the new &lt;code&gt;rec.log&lt;/code&gt;, and nothing was lost. Each &lt;code&gt;printf ... &amp;gt;&amp;gt; rec.log&lt;/code&gt; opens the file by name, so the line after the rename finds the new file.&lt;/p&gt;

&lt;p&gt;The cost is an open and close for every line, which for a loop that logs a few lines a minute is nothing. For a writer that logs thousands of lines a second it would matter, and I did not measure that.&lt;/p&gt;

&lt;p&gt;The same idea works without moving the redirect onto every command: group the work for one clip in &lt;code&gt;{ ...; } &amp;gt;&amp;gt; rec.log&lt;/code&gt;, so the file is reopened once per clip instead of once per line. That version is not in the measured runs above.&lt;/p&gt;

&lt;h2&gt;
  
  
  copytruncate: the window is real
&lt;/h2&gt;

&lt;p&gt;With &lt;code&gt;copytruncate&lt;/code&gt; and the &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; writer, the rotated file got 252 lines, the original 348, and no line was missing. That fits what &lt;code&gt;open(2)&lt;/code&gt; says about append mode: "Before each write(2), the file offset is positioned at the end of the file, as if with lseek(2)." After the truncate, the end of the file is position zero, so the next line starts the new log cleanly.&lt;/p&gt;

&lt;p&gt;It looks safe, and in these runs the window between &lt;code&gt;cp&lt;/code&gt; finishing and the truncate was too short for a line to slip through. The &lt;code&gt;logrotate&lt;/code&gt; manual does not promise that: "Note that there is a very small time slice between copying the file and truncating it, so some logging data might be lost."&lt;/p&gt;

&lt;p&gt;Widening that window to 0.2 seconds shows what lands in it. The writer kept appending after &lt;code&gt;cp&lt;/code&gt; had finished reading, and the truncate then threw those lines away. 17 lines are in neither file. A second full run of the same script lost 16. The exact count depends on timing; a line written between the copy and the truncate is lost in every run.&lt;/p&gt;

&lt;h2&gt;
  
  
  copytruncate under a &lt;code&gt;&amp;gt;&lt;/code&gt; writer: zeros at the top
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;trunc&lt;/strong&gt; writer opened its file with &lt;code&gt;&amp;gt;&lt;/code&gt;, which the Bash manual describes as opening it "for writing" and truncating it if it exists. It is not append mode, so the writer keeps its own position in the file and does not move to the end before each write.&lt;/p&gt;

&lt;p&gt;After &lt;code&gt;copytruncate&lt;/code&gt;, the original was truncated to zero, but the writer's position was still 2580 bytes in. Its next line went there. The result is a &lt;code&gt;rec.log&lt;/code&gt; of 6000 bytes, the size of a full uninterrupted run, starting with 2580 NUL bytes, exactly the size of the rotated copy. &lt;code&gt;grep -c&lt;/code&gt; counts 341 lines in it, but 342 were written there: the first one after the zeros has no newline before it, so it does not start a line, and &lt;code&gt;grep&lt;/code&gt; misses it. The missing-lines check strips the zeros first, which is why it reports nothing lost.&lt;/p&gt;

&lt;p&gt;The second run printed 2560 for both numbers, and a third printed 2530. In every run the zeros matched the size of the copy, wherever the rotation landed.&lt;/p&gt;

&lt;p&gt;An earlier test in this series, &lt;a href="https://dev.to/superfunicular/rm-freed-nothing-and-df-stayed-full-finding-the-process-still-holding-a-deleted-camera-clip-3f67"&gt;rm Freed Nothing and df Stayed Full&lt;/a&gt;, truncated a deleted clip through &lt;code&gt;/proc&lt;/code&gt; under a writer in plain write mode and got the same kind of hole, and it left append mode untested. The rows above fill that gap: under &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; the truncate left no zeros in any run, and under &lt;code&gt;&amp;gt;&lt;/code&gt; the zeros were exactly as long as what the writer had written before the truncate.&lt;/p&gt;

&lt;p&gt;The zeros also change how tools read the file. In a separate quick check on a log rotated the same way, GNU grep 3.7 without &lt;code&gt;-a&lt;/code&gt; printed only &lt;code&gt;grep: rec.log: binary file matches&lt;/code&gt; instead of the lines. Before trusting a log that was rotated with &lt;code&gt;copytruncate&lt;/code&gt;, check which redirect its writer used.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I would do with a long-running script
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Shell loop logging to a file:&lt;/strong&gt; use &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; rather than &lt;code&gt;&amp;gt;&lt;/code&gt;, so that a truncate cannot leave a hole.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rotating it by renaming:&lt;/strong&gt; move the redirect onto the commands inside the loop, or onto a per-clip group, so the writer reopens the name.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rotating with &lt;code&gt;copytruncate&lt;/code&gt;:&lt;/strong&gt; acceptable for a log that can afford to lose a few lines, and only with a &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; writer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A program that can reopen its log on a signal:&lt;/strong&gt; rename and signal. Nothing is lost and nothing is truncated under it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Check the result once:&lt;/strong&gt; after the first rotation, look at whether the new file grows and whether the old one stopped. In the rename runs, the visible sign of trouble was a rotated file that kept growing next to a new one stuck at 0 bytes.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Things I did not test
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;logrotate&lt;/code&gt; itself.&lt;/strong&gt; The rotations here are the steps its &lt;code&gt;create&lt;/code&gt; and &lt;code&gt;copytruncate&lt;/code&gt; directives describe, done by hand with &lt;code&gt;mv&lt;/code&gt;, &lt;code&gt;cp&lt;/code&gt; and a truncate. I did not run &lt;code&gt;logrotate&lt;/code&gt; against the writer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Programs with their own log handling.&lt;/strong&gt; Many daemons and some encoders open, buffer and reopen their logs on their own terms. The writers here are plain shell redirects with no buffering of their own.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Large logs.&lt;/strong&gt; The logs here are a few kilobytes. The slow variant only imitates a long copy with a pause.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Other filesystems.&lt;/strong&gt; &lt;code&gt;stat -f&lt;/code&gt; reported the test directory as &lt;code&gt;ext2/ext3&lt;/code&gt;. Network filesystems treat append mode differently, and the &lt;code&gt;open(2)&lt;/code&gt; page has a warning about that which I did not test.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Sources.&lt;/strong&gt; &lt;code&gt;logrotate&lt;/code&gt; quotes are from the Debian manual page &lt;a href="https://manpages.debian.org/unstable/logrotate/logrotate.8.en.html" rel="noopener noreferrer"&gt;logrotate(8)&lt;/a&gt; for logrotate 3.22.0. Redirection quotes are from the GNU Bash manual page &lt;a href="https://www.gnu.org/software/bash/manual/html_node/Redirections.html" rel="noopener noreferrer"&gt;Bash Reference Manual: Redirections&lt;/a&gt;. The append-mode quote is from the &lt;a href="https://man7.org/linux/man-pages/man2/open.2.html" rel="noopener noreferrer"&gt;Linux open(2) manual page on man7.org&lt;/a&gt;. Outputs are pasted unedited from the script above.&lt;/p&gt;

&lt;p&gt;If an old Android phone is the camera behind the clips that an overnight script works through, the app I make for keeping it recording in the background is &lt;a href="https://play.google.com/store/apps/details?id=com.superfunicular.digicam" rel="noopener noreferrer"&gt;Background Camera RemoteStream on Google Play&lt;/a&gt;. Nothing above depends on it.&lt;/p&gt;

&lt;p&gt;A writer that holds its log open keeps writing to that file after a rename, so rotate a shell loop's log by making the loop reopen the name, and do not &lt;code&gt;copytruncate&lt;/code&gt; a log the writer opened with &lt;code&gt;&amp;gt;&lt;/code&gt;.&lt;/p&gt;

</description>
      <category>bash</category>
      <category>linux</category>
      <category>android</category>
      <category>devops</category>
    </item>
    <item>
      <title>Why Did My Phone Security Camera's Recordings Disappear? Cleaner Apps, Google Photos 'Free Up Space' and 5 More Tools That Delete Footage</title>
      <dc:creator>Super Funicular</dc:creator>
      <pubDate>Tue, 17 Nov 2026 08:14:22 +0000</pubDate>
      <link>https://dev.to/superfunicular/why-did-my-phone-security-cameras-recordings-disappear-cleaner-apps-google-photos-free-up-1c5k</link>
      <guid>https://dev.to/superfunicular/why-did-my-phone-security-cameras-recordings-disappear-cleaner-apps-google-photos-free-up-1c5k</guid>
      <description>&lt;p&gt;On a phone with 32 GB of storage, the warning comes quickly: &lt;strong&gt;"Storage almost full."&lt;/strong&gt; Then the phone offers help. &lt;em&gt;Free up space. Delete large files. Clean junk. Remove unused apps.&lt;/em&gt; One tap, and the phone feels new again.&lt;/p&gt;

&lt;p&gt;If that phone is your security camera, one tap can also remove last week's recordings, or the camera app itself.&lt;/p&gt;

&lt;p&gt;This guide is for a simple setup: an old Android phone used as a home or shop camera, recording to its own storage, often with no cloud account and no internet plan. It goes through each storage-cleaning tool that ships on many Android phones, quotes what Google's own help pages say each one does, and shows how to keep your footage safe in about five minutes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Can a cleaner app delete my phone security camera recordings?
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Short answer:&lt;/strong&gt; Yes. Video recordings are usually the biggest files on a camera phone, so they are exactly what "free up space" tools suggest first. Some tools only &lt;em&gt;suggest&lt;/em&gt; and wait for you to confirm. Others act automatically. And two of them can remove the camera app, which also removes any recordings it kept in its own private folder.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The good news: none of this is hidden. Every tool below is something you can check, switch off, or test before it matters.&lt;/p&gt;

&lt;h2&gt;
  
  
  First, find out where your recordings live
&lt;/h2&gt;

&lt;p&gt;Android gives an app two kinds of places to save files. This decides what can delete them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Shared folders&lt;/strong&gt; like &lt;code&gt;Movies/&lt;/code&gt; or &lt;code&gt;DCIM/&lt;/code&gt;. Your gallery, file manager and Google Photos can all see these files. That makes them easy to copy and share. It also means every cleaning tool can see them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The app's own folder&lt;/strong&gt;, under &lt;code&gt;Android/data/&amp;lt;app name&amp;gt;/&lt;/code&gt;. Other apps mostly cannot see it. But Google's developer documentation is clear about what happens on uninstall:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"When the user uninstalls your app, the files saved in app-specific storage are removed."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Recordings in a &lt;strong&gt;shared folder&lt;/strong&gt; are at risk from cleaners and photo tools.&lt;/li&gt;
&lt;li&gt;Recordings in the &lt;strong&gt;app's own folder&lt;/strong&gt; are at risk from anything that &lt;strong&gt;uninstalls&lt;/strong&gt; the camera app.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To check, open a file manager, look in &lt;code&gt;Movies/&lt;/code&gt; and &lt;code&gt;DCIM/&lt;/code&gt;, and see if your clips are there. We explain both folders, and how to copy footage out, in &lt;a href="https://dev.to/superfunicular/how-to-get-recordings-off-an-old-phone-security-camera-without-a-cloud-account-and-the-folder-17d8"&gt;How to Get Recordings Off an Old-Phone Security Camera Without a Cloud Account&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why camera clips are always "large files"
&lt;/h2&gt;

&lt;p&gt;A rough size guide. File size depends on bitrate, which depends on the app and its settings, so these are examples, not measurements of any specific app:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Example bitrate&lt;/th&gt;
&lt;th&gt;10-minute clip&lt;/th&gt;
&lt;th&gt;1 hour&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;2 Mbit/s&lt;/td&gt;
&lt;td&gt;150 MB&lt;/td&gt;
&lt;td&gt;0.9 GB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4 Mbit/s&lt;/td&gt;
&lt;td&gt;300 MB&lt;/td&gt;
&lt;td&gt;1.8 GB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;8 Mbit/s&lt;/td&gt;
&lt;td&gt;600 MB&lt;/td&gt;
&lt;td&gt;3.6 GB&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;(Size = bitrate × seconds ÷ 8.) A WhatsApp photo is a few hundred kilobytes. One hour of camera footage can be bigger than all of your photos together. Any tool that sorts files by size will put your recordings at the top of the list.&lt;/p&gt;

&lt;h2&gt;
  
  
  The seven storage tools that can remove footage
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Files by Google: "Delete large files"
&lt;/h3&gt;

&lt;p&gt;Files by Google is pre-installed on many budget Android phones. Its &lt;strong&gt;Clean&lt;/strong&gt; screen has a "Delete large files" card. The steps on Google's help page are: tap &lt;strong&gt;Select files&lt;/strong&gt;, choose files, then &lt;strong&gt;Move x file(s) to Trash&lt;/strong&gt; and confirm.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Risk to a camera phone:&lt;/strong&gt; high, because recordings are the large files. It does ask you to select files first, so the risk is a hurried tap, not an automatic delete.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What to do:&lt;/strong&gt; never use "Select all" on this card on a camera phone. Look at the file names first.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Files by Google: "Junk files"
&lt;/h3&gt;

&lt;p&gt;Google describes junk files as temporary files that some apps store. The help page has one important line:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"If you clear junk files or delete files using Files by Google, the data will be permanently deleted."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Risk:&lt;/strong&gt; low for finished recordings (they are normal files, not temporary ones), but there is no Trash here. Use it on a camera phone only when the camera is stopped.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Files by Google: "Delete unused apps"
&lt;/h3&gt;

&lt;p&gt;This card lists apps you have not opened for a while, and offers to uninstall them. To build that list, Files by Google asks for &lt;strong&gt;Usage access&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Here is the problem. A camera app on a dedicated camera phone is an app &lt;strong&gt;you almost never open&lt;/strong&gt;. It runs in the background with the screen off. That is the whole point. So it can look "unused" to any tool that judges apps by how often you open them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Risk:&lt;/strong&gt; high. Uninstalling the camera app stops recording, and (as quoted above) removes any files it kept in its own folder.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What to do:&lt;/strong&gt; do not run this card on the camera phone. If you must, read the list and untick the camera app.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Android's "Archive" and "Manage app if unused"
&lt;/h3&gt;

&lt;p&gt;On Android 15 and newer, Google's help page says an app can be &lt;strong&gt;archived&lt;/strong&gt; to save space. When an app is archived, "your device removes its software, permissions, temporary files, and stops notifications, but retains the app icon and data." It also says supporting app stores can "automatically archive apps that aren't used regularly" if you opt in.&lt;/p&gt;

&lt;p&gt;Your data stays. But the app's software is removed, so &lt;strong&gt;it is not running, and it is not recording.&lt;/strong&gt; The icon stays on the home screen (dimmed), so you might not notice for days.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What to do:&lt;/strong&gt; go to &lt;strong&gt;Settings &amp;gt; Apps &amp;gt;&lt;/strong&gt; your camera app and turn off &lt;strong&gt;Manage app if unused&lt;/strong&gt;. Google's page names this exact toggle for blocking automatic archiving. We cover the older version of this problem, where Android pauses an app and resets its permissions after months unopened, in &lt;a href="https://dev.to/superfunicular/the-camera-app-you-deliberately-never-open-android-hibernation-permission-auto-reset-and-the-one-i4g"&gt;The Camera App You Deliberately Never Open: Android Hibernation, Permission Auto-Reset, and the One Toggle That Prevents Both&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Settings &amp;gt; Storage &amp;gt; Free up space, and "Smart Storage"
&lt;/h3&gt;

&lt;p&gt;Android's own help page describes two things here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A manual list of "photos, videos, and apps that you haven't used recently". You select files, then &lt;strong&gt;Move files to Trash&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Smart Storage&lt;/strong&gt;, which will "automatically clear backed-up photos and videos when your device's storage is almost full."&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The Files by Google page for Smart Storage gives the rules: backed-up photos are deleted automatically "If photos are saved for 60 days" or "If your device's storage is less than 25%." It also says this automatic deletion "is only available for Pixels users on Android S." The Android help page says some steps "only work on Android 14 and up." So this depends a lot on the phone.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Risk:&lt;/strong&gt; it only removes items that are &lt;strong&gt;backed up&lt;/strong&gt;. On an offline camera phone with no Google Photos backup, it has nothing to remove. If backup is on, see the next point.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Google Photos: backup, then "Free up space on this device"
&lt;/h3&gt;

&lt;p&gt;This one has two steps, and the first one happens quietly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step one: backup.&lt;/strong&gt; Google Photos does not only back up the camera folder. Its help page says: "When you turn 'Backup' on, your chosen device folders are automatically backed up too, not only your camera." And if &lt;strong&gt;Back up all device folders&lt;/strong&gt; is on, "photos in new device folders automatically back up." Videos up to 10 GB can be backed up.&lt;/p&gt;

&lt;p&gt;So a camera app's recordings folder can start uploading without you choosing it. On a prepaid SIM, that is mobile data you did not plan for (we did the data maths for streaming in &lt;a href="https://dev.to/superfunicular/why-does-my-phone-cameras-live-stream-stop-after-a-few-hours-on-mobile-data-the-15-gbday-limit-341l"&gt;Why Does My Phone Camera's Live Stream Stop After a Few Hours on Mobile Data?&lt;/a&gt;). Your private camera footage also ends up in your Google account.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step two: "Free up space on this device."&lt;/strong&gt; This deletes the phone's copy of everything that is backed up. Google's help page warns: "This feature deletes photos from your device." After that, you can still see the videos in Google Photos online, but &lt;strong&gt;not&lt;/strong&gt; if:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"You use your mobile device's built-in gallery."&lt;/li&gt;
&lt;li&gt;"You're offline."&lt;/li&gt;
&lt;li&gt;"You're not signed in to the Google Photos app."&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For a camera that is supposed to work &lt;strong&gt;without internet&lt;/strong&gt;, that is the wrong place for your footage to end up.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What to do on the camera phone:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open Google Photos &amp;gt; profile picture &amp;gt; &lt;strong&gt;Photos settings &amp;gt; Backup&lt;/strong&gt;. Turn Backup off, or open &lt;strong&gt;Back up device folders&lt;/strong&gt; and switch off your camera app's folder. Also turn off &lt;strong&gt;Back up all device folders&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;If you keep backup on, go to &lt;strong&gt;Backup &amp;gt; Mobile data usage&lt;/strong&gt; and turn off &lt;strong&gt;Back up videos over data&lt;/strong&gt;, or set a daily limit.&lt;/li&gt;
&lt;li&gt;Do not tap &lt;strong&gt;Free up space on this device&lt;/strong&gt; on a camera phone.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  7. Settings &amp;gt; Apps &amp;gt; camera app &amp;gt; "Clear storage"
&lt;/h3&gt;

&lt;p&gt;People often get the advice "clear the app's data" when an app misbehaves. Google's Android help page explains the difference:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Clear cache:&lt;/strong&gt; "Deletes temporary data."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Clear storage:&lt;/strong&gt; "Permanently deletes all app data."&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On a camera app, "all app data" includes your settings, and may include recordings that live in the app's own folder.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What to do:&lt;/strong&gt; if the camera app has a problem, try &lt;strong&gt;Clear cache&lt;/strong&gt; first. Copy your recordings off the phone before you ever tap &lt;strong&gt;Clear storage&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What about the phone maker's cleaner?
&lt;/h2&gt;

&lt;p&gt;Many budget phones also have their own cleaner built in, like Phone Master on Tecno, Infinix and itel phones, or the Security app's cleaner on Xiaomi, Redmi and POCO. We cannot see inside those apps, so we will not guess exactly what they delete. The safe rule is the same: &lt;strong&gt;never accept a one-tap "boost" or "clean" on a camera phone without reading the list.&lt;/strong&gt; Our brand guides show where these settings live: &lt;a href="https://dev.to/superfunicular/why-does-my-tecno-infinix-or-itel-phone-stop-the-camera-app-with-the-screen-off-phone-master-fa4"&gt;Tecno, Infinix and itel&lt;/a&gt; and &lt;a href="https://dev.to/superfunicular/why-does-my-redmi-poco-or-xiaomi-phone-stop-the-camera-app-with-the-screen-off-autostart-battery-29kg"&gt;Redmi, POCO and Xiaomi&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick summary table
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;Acts by itself?&lt;/th&gt;
&lt;th&gt;Can remove recordings?&lt;/th&gt;
&lt;th&gt;Can remove the camera app?&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Files by Google: Delete large files&lt;/td&gt;
&lt;td&gt;No, you select&lt;/td&gt;
&lt;td&gt;Yes (to Trash)&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Files by Google: Junk files&lt;/td&gt;
&lt;td&gt;No, you confirm&lt;/td&gt;
&lt;td&gt;Unlikely; permanent&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Files by Google: Delete unused apps&lt;/td&gt;
&lt;td&gt;No, you select&lt;/td&gt;
&lt;td&gt;Yes, via uninstall&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Yes&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Android archive / Manage app if unused&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Can be automatic&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;No (data kept)&lt;/td&gt;
&lt;td&gt;Stops it running&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Settings: Free up space&lt;/td&gt;
&lt;td&gt;No, you select&lt;/td&gt;
&lt;td&gt;Yes (to Trash)&lt;/td&gt;
&lt;td&gt;Yes, if you pick it&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Smart Storage&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Automatic&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Only backed-up items&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Google Photos: Free up space on this device&lt;/td&gt;
&lt;td&gt;No, you confirm&lt;/td&gt;
&lt;td&gt;Phone copies of backed-up items&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Clear storage (camera app)&lt;/td&gt;
&lt;td&gt;No, you confirm&lt;/td&gt;
&lt;td&gt;Possibly, if in app's folder&lt;/td&gt;
&lt;td&gt;No, but resets it&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  How to keep footage safe on an offline camera phone
&lt;/h2&gt;

&lt;p&gt;This works without internet and without a Google account on the camera phone:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Give recordings room so the warning never appears.&lt;/strong&gt; Delete old recordings yourself, on your own schedule. An SD card helps if the phone has a slot; test it first with &lt;a href="https://dev.to/superfunicular/is-my-cheap-128-gb-sd-card-fake-how-to-test-a-memory-card-before-it-goes-in-an-offline-phone-dd0"&gt;Is My Cheap 128 GB SD Card Fake?&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Copy important clips off the phone the same day.&lt;/strong&gt; A computer, a second phone, or a USB drive. One copy is not a backup.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Turn off Google Photos backup&lt;/strong&gt; on the camera phone, or remove the camera folder from it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Turn off "Manage app if unused"&lt;/strong&gt; for the camera app.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Do not run "Delete unused apps" or one-tap cleaners&lt;/strong&gt; on the camera phone.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;If other people use the phone&lt;/strong&gt; (family, shop staff), tell them: this phone's storage warning is not a problem to fix.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  A two-minute test you can do today
&lt;/h2&gt;

&lt;p&gt;You do not need to trust any of this. Check your own phone, without deleting anything:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Record a short test clip with your camera app.&lt;/li&gt;
&lt;li&gt;Open Files by Google &amp;gt; &lt;strong&gt;Clean&lt;/strong&gt;. Look at &lt;strong&gt;Delete large files&lt;/strong&gt;. Is your test clip in the list? Then &lt;strong&gt;go back without confirming&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;If you see a &lt;strong&gt;Delete unused apps&lt;/strong&gt; card, open it and check if your camera app is listed. Go back without confirming.&lt;/li&gt;
&lt;li&gt;Open Google Photos &amp;gt; &lt;strong&gt;Backup &amp;gt; Back up device folders&lt;/strong&gt;. Is your camera folder switched on?&lt;/li&gt;
&lt;li&gt;Open &lt;strong&gt;Settings &amp;gt; Apps &amp;gt;&lt;/strong&gt; your camera app. Is &lt;strong&gt;Manage app if unused&lt;/strong&gt; on?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Every "yes" is one way your recordings could disappear. Every one can be switched off today.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Background Camera RemoteStream&lt;/strong&gt; turns an Android phone into a screen-off camera: it records with the screen off and keeps recordings on the phone, with no cloud account needed. Its Pro tier adds a live browser view over your own Wi-Fi and YouTube Live streaming; check the Play listing for what is free and what is Pro.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Google Play: &lt;a href="https://play.google.com/store/apps/details?id=com.superfunicular.digicam" rel="noopener noreferrer"&gt;https://play.google.com/store/apps/details?id=com.superfunicular.digicam&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Website: &lt;a href="https://superfunicular.com" rel="noopener noreferrer"&gt;https://superfunicular.com&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Sources&lt;/strong&gt; (all read on 17 November 2026)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Android Developers: &lt;a href="https://developer.android.com/training/data-storage/app-specific" rel="noopener noreferrer"&gt;Access app-specific files&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Android Help: &lt;a href="https://support.google.com/android/answer/7431795?hl=en" rel="noopener noreferrer"&gt;Free up storage on your Android device&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Android Help: &lt;a href="https://support.google.com/android/answer/15523443" rel="noopener noreferrer"&gt;Archive unused apps on Android&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Files by Google Help: &lt;a href="https://support.google.com/files/answer/10434652?hl=en" rel="noopener noreferrer"&gt;Delete large files&lt;/a&gt;, &lt;a href="https://support.google.com/files/answer/9713869?hl=en" rel="noopener noreferrer"&gt;Clear your junk files&lt;/a&gt;, &lt;a href="https://support.google.com/files/answer/9765112?hl=en" rel="noopener noreferrer"&gt;Delete unused apps and free up space&lt;/a&gt;, &lt;a href="https://support.google.com/files/answer/10862356?hl=en" rel="noopener noreferrer"&gt;Delete backed-up photos automatically&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Google Photos Help: &lt;a href="https://support.google.com/photos/answer/6193313?hl=en&amp;amp;co=GENIE.Platform%3DAndroid" rel="noopener noreferrer"&gt;Back up photos &amp;amp; videos&lt;/a&gt;, &lt;a href="https://support.google.com/photos/answer/6128843?hl=en&amp;amp;co=GENIE.Platform%3DAndroid" rel="noopener noreferrer"&gt;Free up space on your device&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>android</category>
      <category>tutorial</category>
      <category>privacy</category>
      <category>security</category>
    </item>
  </channel>
</rss>
