I am trying to run an AWS CLI command in my pod. As the pod may take some time to complete i am trying to run it in the background Here is my command
kubectl -it exec <podname> -- bash -c "aws s3api list-objects --bucket bucketname-1 --query 'Contents[?StorageClass==\"ONEZONE_IA\"].[Key,StorageClass]' --output text > /storage/ONEZONE_keys1.txt &"
when I run this command it becomes a defunct process
when I run the command without the &
in the end it works fine
But the process gets terminated once the terminal is closed
Ultimately I just want to run this command as a cron job every day
Not sure whats wrong ,or this whole process can be done in a better way
Any help is much appreciated, Thank you
CodePudding user response:
I think nohup can help on this scenario. Try to execute this command with "nohup".
Ex-
nohup "your command" > "redirect file-name" &