Hello, I’d like to run a background process inside of the okteto replaced container in my deployment. I run an okteto up, then a process inside of the container (like nohup ./script.sh &), and then exit the container.
I would expect the process to still run and logging appending to a nohup.out, but I don’t see logging and when I get back into the container with an okteto up, I see the process isn’t running.
I’ve also tried okteto exec nohup ./script.sh & while I’m okteto up’d, but I get this: [2] + 71789 suspended (tty output) okteto exec a0 nohup ./script.sh which I don’t think is correct.
Just so I am sure I am understanding your workflow. When you say the ...and then exit the container., do you mean in your terminal you do something like Ctrl+C?
Or did you exec into the Pod and started the process, and then you exit the Pod shell?
Sorry for the delay. I was trying to reproduce and was able to have a running process with the following steps:
1- Run okteto up in my local terminal.
2- Within the container terminal spawned by okteto up, I was able to run the same command as you nohup ./script.sh &
3- I can see in my local file that the test file is receiving output from the nohup process.
4- Exit out of the okteto up process. Here, I can tell that my local file is no longer receiving output. This makes sense, because in the background, okteto up runs syncthing to make sure that files are synchronized locally and remotely. However, when okteto up is exited, syncthing is no longer running.
5- I exec into the Pod with the command: kubectl exec --stdin --tty <my pod> -- /bin/bash
6- I check the output of my test file, and I can see that it is still having new lines added from the nohup process.
So in short, the syncthing process stopped when I exited out of okteto up, and therefore my local file no longer received the nohup changes. However, inside the remote container, nohup is still writing into the test file.
This was my script:
#!/bin/bash
# Get the current line number
line_number=$((line_number + 1))
# Append the text "line goes here <line number>" to the file
echo "line goes here $line_number" >> testFile.txt
# Sleep for two seconds
sleep 2
# Repeat the process forever
while true; do
# Get the current line number
line_number=$((line_number + 1))
# Append the text "line goes here <line number>" to the file
echo "line goes here $line_number" >> testFile.txt
# Sleep for two seconds
sleep 2
done
Was your script somethign similar? Also, are both test files (local and remote) not being written to?