<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: pv-pod
  namespace: auth
spec:
  containers:
  - name: busybox
    image: busybox
    #************** HERE is the command!
    command: ['sh', '-c', 'while true; do echo date &gt; /output/output.log; sleep 5; done']
    volumeMounts:
    - name: pv-storage
      mountPath: /output
  volumes:
  - name: pv-storage
    persistentVolumeClaim:
      claimName: host-storage-pvc
</code></pre>
<p>This command is where i need to insert into a file &quot;success! Wed Jun  8 20:28:01 WAST 2022&quot;,i.e. current timestamp.</p>
<pre><code>command: ['sh', '-c', 'while true; do echo success! $date &gt;&gt; /output/output.log; sleep 5; done']
</code></pre>
<p>But it keeps writing 'success date'</p>

ERJAN
<p>You could use <a href="https://unix.stackexchange.com/questions/440088/what-is-command-substitution-in-a-shell">command substitution</a> for this. That would be in shell or bash, the same.</p>
<p>Additionally, you may need to escape the dollar sign, since <code>$()</code> has a <a href="https://kubernetes.io/docs/tasks/inject-data-application/define-interdependent-environment-variables/#define-an-environment-dependent-variable-for-a-container" rel="nofollow noreferrer">special meaning in Kubernetes manifests</a>.</p>
<pre class="lang-bash prettyprint-override"><code>echo &quot;success $$(date)&quot; &gt;&gt; ...
</code></pre>
